[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

array -> list

Wybo Dekker

11/15/2003 12:23:00 PM

4 Answers

ts

11/15/2003 12:32:00 PM

0

>>>>> "W" == Wybo Dekker <wybo@servalys.nl> writes:

W> printf("%04d-%02d-%02d %02d:%02d\n", ParseDate.parse(datestring)

svg% ruby -rparsedate > -e 'printf("%04d-%02d-%02d %02d:%02d\n", *ParseDate.parsedate(Time.now.to_s))'
2003-11-15 13:31
svg%


Guy Decoux

gabriele renzi

11/15/2003 3:20:00 PM

0

il Sat, 15 Nov 2003 21:23:09 +0900, Wybo Dekker <wybo@servalys.nl> ha
scritto::

>Is there a way to convert an array to a (parameter-)list?
>
>I often find myself doing things like:
>
> year,mon,day,hour,minute = ParseDate.parse(datestring)
> printf("%04d-%02d-%02d %02d:%02d\n",year,mon,day,hour,minute)
>
>while it would be a lot nicer to do:
>
> printf("%04d-%02d-%02d %02d:%02d\n", ParseDate.parse(datestring)

just use a * just before an array to make it a list of parameters.

Btw, maybe you could just use
print Date.strftime(yourformat)

Fred Werne

11/15/2003 10:29:00 PM

0

Hi Wybo

Wybo Dekker schrieb:
>
> Is there a way to convert an array to a (parameter-)list?

Do you mean *anArray ?

> I often find myself doing things like:
>
> year,mon,day,hour,minute = ParseDate.parse(datestring)
> printf("%04d-%02d-%02d %02d:%02d\n",year,mon,day,hour,minute)
>
> while it would be a lot nicer to do:
>
> printf("%04d-%02d-%02d %02d:%02d\n", ParseDate.parse(datestring)

I tested the following
---------------------------------------------------
dateArray = [1973,11,9,11,30]
printf("%04d-%02d-%02d %02d:%02d\n", *dateArray)
---------------------------------------------------
It works.

I don't have a class ParseDate with a method parse,
but if it returns an Array, I think

printf("%04d-%02d-%02d %02d:%02d\n", *ParseDate.parse(datestring))
^ ^

will work.

I hope, I understand your problem.

Regards

Fred from Wuppertal, Germany

Wybo Dekker

11/16/2003 5:42:00 PM

0