Just say I have strings that I’ve already written:
“a= 340”
“abc= 340”
“acbfdhdfdf= 340”
…
I want the output to look like this:
“a= 340”
“abc= 340”
“acbfdhdfdf= 340”
Thanks!
Just say I have strings that I’ve already written:
“a= 340”
“abc= 340”
“acbfdhdfdf= 340”
…
I want the output to look like this:
“a= 340”
“abc= 340”
“acbfdhdfdf= 340”
Thanks!
From: [email protected] [mailto:[email protected]]
some ways,
ar
#=> [“a= 340”, “abc= 340”, “acbfdhdfdf= 340”]
fixw
#=> 15
ar.each {|x| puts “%-#{fixw}s%d” % x.split}
a= 340
abc= 340
acbfdhdfdf= 340
puts ar.map {|x| “%-#{fixw}s%d” % x.split}
a= 340
abc= 340
acbfdhdfdf= 340
ar.each {|x| puts x.split.map{|y| y.ljust(fixw)}.join }
a= 340
abc= 340
acbfdhdfdf= 340
puts ar.map {|x| x.split.map{|y| y.ljust(fixw)}.join }
a= 340
abc= 340
acbfdhdfdf= 340
kind regards -botp
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs