On Sun, Jan 1, 2012 at 9:57 PM, Linus Phan <linusphan / yahoo.com> wrote:

> Hello,
>
> I am still learning Ruby, my question is,
>
> what is a string and what is a string literal? If possible, can you give
> me an example of both. Any help would be much appreciated.
>

First Google hit for "ruby doc string"
#=>  http://ruby-doc.org/core-1.9.3/String.html

"... A String object holds and manipulates an
arbitrary sequence of bytes, typically representing characters. ..."

A string literal is piece of _code_ that is used to initialize a string:

E.g.

  "this is a string literal"

so the line

  s = "this is a string literal"

assigns the string literal (the part between " ") to the string s.

HTH,

Peter




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


-- 
Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com
gsm: +32-478-27.40.69
e-mail: peter / vandenabeele.com