Two Question

Hi everybody
I have two question :
1 - What is the exact meaning of Literals in Ruby ?
2 - What is the use of “puts” in Ruby and what is diffrence between
“puts” and “print” ?

n Thu, Jul 22, 2010 at 10:59 AM, Amir E. [email protected]
wrote:

Hi everybody
I have two question :
1 - What is the exact meaning of Literals in Ruby ?

http://ruby-doc.org/docs/ProgrammingRuby/html/language.html

Take a look at the section: The Basic Types.

2 - What is the use of “puts” in Ruby and what is diffrence between
“puts” and “print” ?

As Josh says it’s easy to try and see:

puts “a”
puts “b”
print “a”
print “b”

Or also, you can read the explanation here:

puts: class IO - RDoc Documentation
print: module Kernel - RDoc Documentation

Jesus.

Unsubscribe

Sent from my iPhone

On Thu, Jul 22, 2010 at 3:59 AM, Amir E. [email protected]
wrote:

Hi everybody
I have two question :
1 - What is the exact meaning of Literals in Ruby ?
2 - What is the use of “puts” in Ruby and what is diffrence between
“puts” and “print” ?

Posted via http://www.ruby-forum.com/.

regarding 2:

5.times { puts “abc” }
5.times { print “xyz” }

1-
lit·er·al
n accordance with, involving, or being the primary or strictmeaning of the w
ord or words; not figurative ormetaphorical: the literal meaning of a word.

There for a RUBY literal String is as follows:

“this is a string, literally”

http://ruby-doc.org/docs/ProgrammingRuby/html/language.html

2 -
irb(main):005:0> 5.times { print " print output no newline " }
print output no newline print output no newline print output no
newline
print output no newline print output no newline => 5
irb(main):006:0> 5.times { puts " puts output has a newline " }
puts output has a newline
puts output has a newline
puts output has a newline
puts output has a newline
puts output has a newline
=> 5