string and fixnum(float) concatenation....

J

Jun Young Kim

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

Peña, Botp

From: Pe=F1a, Botp [mailto:[email protected]]=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
 
S

Simon Krahnke

* Jun Young Kim said:
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
 
J

Jun Young Kim

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:[email protected]]
#...
# 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)
***************************
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top