How do you write to STDOUT in Ruby?

Answer

Actually two methods are available:

puts writes with a newline

print writes without a newline

 

 

We use print / puts methods to print something..

Difference between print and puts:

 

example:

a = (1..20).to_a

for i in a

print i

end

o/p: 1 2 3 4 ...20

 

 

example:

 

a = (1..20).to_a

for i in a

puts i

end

 

1

2

3

4

.

.

20

All ruby Questions

Ask your interview questions on ruby

Write Your comment or Questions if you want the answers on ruby from ruby Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---