From: Amir Ebrahimifard on
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/.

From: Josh Cheek on
[Note: parts of this message were removed to make it a legal post.]

On Thu, Jul 22, 2010 at 3:59 AM, Amir Ebrahimifard <amiref(a)ymail.com> 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" }

From: Jesús Gabriel y Galán on
n Thu, Jul 22, 2010 at 10:59 AM, Amir Ebrahimifard <amiref(a)ymail.com> 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: http://ruby-doc.org/core/classes/IO.html#M002252
print: http://ruby-doc.org/core/classes/Kernel.html#M005952

Jesus.

From: Joseph E. Savard on

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



> From: Amir Ebrahimifard <amiref(a)ymail.com>
> Reply-To: <ruby-talk(a)ruby-lang.org>
> Newsgroups: comp.lang.ruby
> Date: Thu, 22 Jul 2010 17:59:45 +0900
> To: ruby-talk ML <ruby-talk(a)ruby-lang.org>
> Subject: 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" ?
> --
> Posted via http://www.ruby-forum.com/.
>