Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > string and fixnum(float) concatenation....

Reply
Thread Tools

string and fixnum(float) concatenation....

 
 
Jun Young Kim
Guest
Posts: n/a
 
      02-24-2009
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?

 
Reply With Quote
 
 
 
 
Peņa, Botp
Guest
Posts: n/a
 
      02-24-2009
From: Jun Young Kim [private.php?do=newpm&u=]=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"

 
Reply With Quote
 
 
 
 
Peņa, Botp
Guest
Posts: n/a
 
      02-24-2009
From: Pe=F1a, Botp [private.php?do=newpm&u=]=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

 
Reply With Quote
 
Simon Krahnke
Guest
Posts: n/a
 
      02-24-2009
* Jun Young Kim <> (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

 
Reply With Quote
 
Jun Young Kim
Guest
Posts: n/a
 
      02-24-2009
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 [private.php?do=newpm&u=]
> #...
> # 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)
***************************






 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is "String s = "abc";" equal to "String s = new String("abc");"? Bruce Sam Java 15 11-19-2004 06:03 PM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
Counting occurances of string A in string B, and adding it to string B Sandman Perl Misc 7 08-03-2004 08:46 PM
String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 3 12-05-2003 04:20 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57