Some methods don't work in WinXP?

B

Bob

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
 
T

ts

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
 
J

Joao Pedrosa

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
 
P

Premshree Pillai

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? :)
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
 
B

Bob

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

One huge Homer Simpson DUH!

Thanks

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top