Some methods don't work in WinXP?

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

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%

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

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

Guy Decoux

Hi,

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

···

On Wed, 29 Dec 2004 00:51:48 +0900, Bob <clarke@qualitythink.com> wrote:

Hi,

> 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? :slight_smile:

···

On Wed, 29 Dec 2004 00:59:14 +0900, Joao Pedrosa <joaopedrosa@gmail.com> wrote:

On Wed, 29 Dec 2004 00:51:48 +0900, Bob <clarke@qualitythink.com> wrote:

>
> 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

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

One huge Homer Simpson DUH!

Thanks

ts wrote:

> 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%

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

yada

···

> #(inline_string) yada yada" not "yada yada yo yada yada"

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

Guy Decoux