Some methods don't work in WinXP?

Discussion in 'Ruby' started by Bob, Dec 28, 2004.

  1. Bob

    Bob Guest

    Do some methods / functions not work in the WinXP implementation?

    The array sort do not seem to work.

    a=["b", "a", "d"]

    print a => bad

    a.sort

    print a => bad

    (this is right out of the documentation!)

    and

    inline_string="yo"

    print "yada yada #(inline_string) yada yada " =>prints as "yada yada
    #(inline_string) yada yada" not "yada yada yo yada yada"

    What gives, I am missing a library or something?
    I installed the windows one click installer.
    Runing WinXp pro, Xitami webserver,

    thanks
    bobc
    Bob, Dec 28, 2004
    #1
    1. Advertising

  2. Bob

    ts Guest

    >>>>> "B" == Bob <> writes:

    B> a.sort

    Array#sort return a copy of the array.

    uln% ruby -e 'a=["b", "a", "d"]; b = a.sort; p a, b'
    ["b", "a", "d"]
    ["a", "b", "d"]
    uln%

    You want Array#sort! if you want modify the object

    uln% ruby -e 'a=["b", "a", "d"]; a.sort!; p a'
    ["a", "b", "d"]
    uln%


    B> print "yada yada #(inline_string) yada yada " =>prints as "yada yada
    B> #(inline_string) yada yada" not "yada yada yo yada yada"

    You want #{inline_string}, i.e. {} rather than ()



    Guy Decoux
    ts, Dec 28, 2004
    #2
    1. Advertising

  3. Bob

    Joao Pedrosa Guest

    Hi,

    On Wed, 29 Dec 2004 00:51:48 +0900, Bob <> wrote:
    > Do some methods / functions not work in the WinXP implementation?
    >
    > The array sort do not seem to work.
    >
    > a=["b", "a", "d"]
    >
    > print a => bad
    >
    > a.sort


    You need a.sort! if you wish the elements in the array to be changed.
    In Ruby, the exclamation mark is used in the method if it changes
    something in its object. Or else, you can a = a.sort and recapture the
    sorted array.

    >
    > print a => bad
    >
    > (this is right out of the documentation!)
    >
    > and
    >
    > inline_string="yo"
    >
    > print "yada yada #(inline_string) yada yada " =>prints as "yada yada
    > #(inline_string) yada yada" not "yada yada yo yada yada"


    Instead of parentheses, you need {} (At the moment it does not occur
    to me how they are called in English.)

    >
    > What gives, I am missing a library or something?
    > I installed the windows one click installer.
    > Runing WinXp pro, Xitami webserver,
    >
    > thanks
    > bobc


    Cheers,
    Joao
    Joao Pedrosa, Dec 28, 2004
    #3
  4. On Wed, 29 Dec 2004 00:59:14 +0900, Joao Pedrosa <> wrote:
    > Hi,
    >
    > On Wed, 29 Dec 2004 00:51:48 +0900, Bob <> wrote:
    > > Do some methods / functions not work in the WinXP implementation?
    > >
    > > The array sort do not seem to work.
    > >
    > > a=["b", "a", "d"]
    > >
    > > print a => bad
    > >
    > > a.sort

    >
    > You need a.sort! if you wish the elements in the array to be changed.
    > In Ruby, the exclamation mark is used in the method if it changes
    > something in its object. Or else, you can a = a.sort and recapture the
    > sorted array.
    >
    > >
    > > print a => bad
    > >
    > > (this is right out of the documentation!)
    > >
    > > and
    > >
    > > inline_string="yo"
    > >
    > > print "yada yada #(inline_string) yada yada " =>prints as "yada yada
    > > #(inline_string) yada yada" not "yada yada yo yada yada"

    >
    > Instead of parentheses, you need {} (At the moment it does not occur
    > to me how they are called in English.)

    Braces? :)
    >
    > >
    > > What gives, I am missing a library or something?
    > > I installed the windows one click installer.
    > > Runing WinXp pro, Xitami webserver,
    > >
    > > thanks
    > > bobc

    >
    > Cheers,
    > Joao
    >
    >



    --
    Premshree Pillai
    http://www.livejournal.com/~premshree
    Premshree Pillai, Dec 28, 2004
    #4
  5. Bob

    Bob Guest

    Can you hear the screams from Connecticut? (USA).

    One huge Homer Simpson DUH!

    Thanks


    ts wrote:
    > >>>>> "B" == Bob <> writes:

    >
    > B> a.sort
    >
    > Array#sort return a copy of the array.
    >
    > uln% ruby -e 'a=["b", "a", "d"]; b = a.sort; p a, b'
    > ["b", "a", "d"]
    > ["a", "b", "d"]
    > uln%
    >
    > You want Array#sort! if you want modify the object
    >
    > uln% ruby -e 'a=["b", "a", "d"]; a.sort!; p a'
    > ["a", "b", "d"]
    > uln%
    >
    >
    > B> print "yada yada #(inline_string) yada yada " =>prints as "yada

    yada
    > B> #(inline_string) yada yada" not "yada yada yo yada yada"
    >
    > You want #{inline_string}, i.e. {} rather than ()
    >
    >
    >
    > Guy Decoux
    Bob, Dec 28, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jobs
    Replies:
    0
    Views:
    372
  2. Gustavo Narea
    Replies:
    13
    Views:
    446
    Gustavo Narea
    Jun 21, 2009
  3. jcvoon
    Replies:
    0
    Views:
    360
    jcvoon
    Nov 6, 2007
  4. kriani
    Replies:
    1
    Views:
    204
  5. Kenneth McDonald
    Replies:
    5
    Views:
    314
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page