Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,690 questions

55,449 answers

573 users

How to print array in Ruby

3 Answers

0 votes
arr = ["Ruby", "Open", "Source", "Programming", "Language"]

arr.each do |s|
    puts s
end



 
#
# run:
# 
# Ruby
# Open
# Source
# Programming
# Language
# 

 



answered Oct 16, 2021 by avibootz
0 votes
def display(arr) 
	i = 0
	while (i < arr.length) 
		print(arr[i], " ")
		i += 1
	end
end
	
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]


display(arr)




#
# run:
# 
# 1 2 3 4 5 6 7 8 9 0 
#

 



answered Oct 31, 2021 by avibootz
0 votes
array = [1, 2, 3, 4, 5, 6]

array.each { |x| puts x }


  
# run:
# 
# 1
# 2
# 3
# 4
# 5
# 6
#

 



answered Mar 22, 2025 by avibootz

Related questions

1 answer 139 views
1 answer 235 views
1 answer 266 views
266 views asked Dec 23, 2020 by avibootz
1 answer 205 views
205 views asked Dec 23, 2020 by avibootz
1 answer 213 views
1 answer 209 views
209 views asked Nov 7, 2020 by avibootz
1 answer 166 views
166 views asked Nov 7, 2020 by avibootz
...