String output to STDOUT : STDOUT « Language Basics « Ruby






String output to STDOUT



o = STDOUT

o << x             # Output x.to_s
o << x << y        # May be chained: output x.to_s + y.to_s
o.print            # Output $_ + $\
o.print s          # Output s.to_s + $\
o.print s,t        # Output s.to_s + t.to_s + $\
o.printf fmt,*args # Outputs fmt%[args]
o.puts             # Output newline
o.puts x           # Output x.to_s.chomp plus newline
o.puts x,y         # Output x.to_s.chomp, newline, y.to_s.chomp, newline
o.puts [x,y]       # Same as above
o.write s          # Output s.to_s, returns s.to_s.length
o.syswrite s       # Low-level version of write

 








Related examples in the same category

1.Single-character output