[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

string and fixnum(float) concatenation....

? ??

2/24/2009 6:13:00 AM

hi, forks...

see this source

irb(main):015:0> puts "%*s" % [ "1", 2 ]
TypeError: can't convert String into Integer
from (irb):15:in `%'
from (irb):15
from :0
irb(main):016:0>

AIK, "%*s" is to use for concatenation of array.

but, I met the previous error message.

What's different ways I can take?

4 Answers

Peña, Botp

2/24/2009 6:52:00 AM

0

From: Jun Young Kim [mailto:jykim@altibase.com]=20
#...
# AIK, "%*s" is to use for concatenation of array.

can you point me a link to that info?


afaik, "*" is used for field widths, eg,

> p "%*s" % [2,"1"]
" 1"

> p "%*s" % [2,1]
" 1"

> p "%.*s" % [2,"abcdef"]
"ab"

Peña, Botp

2/24/2009 6:58:00 AM

0

From: Pe=F1a, Botp [mailto:botp@delmonte-phil.com]=20
#
# afaik, "*" is used for field widths, eg,

or precisions

#=20
# > p "%*s" % [2,"1"]
# " 1"
#=20
# > p "%*s" % [2,1]
# " 1"
#=20
# > p "%.*s" % [2,"abcdef"]
# "ab"
#=20

also, if just plain concat, %s will do

> puts "%s" % [["1", 2]]
12

Simon Krahnke

2/24/2009 7:16:00 AM

0

* Jun Young Kim <jykim@altibase.com> (07:13) schrieb:

> irb(main):015:0> puts "%*s" % [ "1", 2 ]
> TypeError: can't convert String into Integer
> from (irb):15:in `%'
> from (irb):15
> from :0
> irb(main):016:0>

Maybe you meant "%*s" % [ 2, "1" ] if you expect " 1".

mfg, simon .... l

? ??

2/24/2009 7:48:00 AM

0

thanks, wrong knowledge is more worse than wrong action.

2009. 02. 24, =EC=98=A4=ED=9B=84 3:52, Pe=C3=B1a, Botp =EC=9E=91=EC=84=B1:=


> From: Jun Young Kim [mailto:jykim@altibase.com]
> #...
> # AIK, "%*s" is to use for concatenation of array.
>
> can you point me a link to that info?
>
>
> afaik, "*" is used for field widths, eg,
>
>> p "%*s" % [2,"1"]
> " 1"
>
>> p "%*s" % [2,1]
> " 1"
>
>> p "%.*s" % [2,"abcdef"]
> "ab"
>
>


***************************
DSLab, CQ =EA=B9=80=EC=A4=80=EC=98=81 =EB=93=9C=EB=A6=BC
(02-2082-1091)
***************************