[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Some methods don't work in WinXP?

Bob

12/28/2004 3:49:00 PM

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

4 Answers

ts

12/28/2004 3:56:00 PM

0

>>>>> "B" == Bob <clarke@qualitythink.com> 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






Joao Pedrosa

12/28/2004 3:59:00 PM

0

Hi,

On Wed, 29 Dec 2004 00:51:48 +0900, Bob <clarke@qualitythink.com> 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


Premshree Pillai

12/28/2004 4:09:00 PM

0

On Wed, 29 Dec 2004 00:59:14 +0900, Joao Pedrosa <joaopedrosa@gmail.com> wrote:
> Hi,
>
> On Wed, 29 Dec 2004 00:51:48 +0900, Bob <clarke@qualitythink.com> 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/...


Bob

12/28/2004 8:32:00 PM

0

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

One huge Homer Simpson DUH!

Thanks


ts wrote:
> >>>>> "B" == Bob <clarke@qualitythink.com> 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