hello,
how to create a string from variables containing numeric values of range
0…255?
print “\32\32\32” # => ’ ’
#i tried the following:
a = 32
"\#{a}"*3 # => ‘\32\32\32’
now i would like to let ruby process the result again to get the desired
result ’ '.
- how to invoke string processing?
- there must be an easier way to assemle characters to a string?
Hi,
Meinrad Recheis meinrad.recheis@aon.at writes:
how to create a string from variables containing numeric values of range
0…255?
print “\32\32\32” # => ’ ’
#i tried the following:
a = 32
“\#{a}”*3 # => ‘\32\32\32’
now i would like to let ruby process the result again to get the desired
result ’ '.
% irb
a = 32
=> 32
a.chr * 3
=> " "
format(“%c”, a) * 3
=> " "
(“%c” % a) * 3
=> " "
([a].pack “c”) * 3
=> " "
···
–
eban
a = 32
s = ‘’ << a # => ’ ’