W
warhero
how can I accomplish something like this in ruby:
pseudo code:
word = "picture"
for( i = 0; i < word.length; i++ )
{
puts( word.substr(i,1) )
}
ruby?
I've tried something like:
word = "picture"
word.each { |char| puts char }
but that doesn't do what I am wanting. it ends up just putting the
entire word "picture"
I've also tried:
word = "picture"
for i in 0..word.length - 1
puts word
end
that just puts out ascii numbers..
I thought strings could be access like arrays?
word = "picture"
puts word[0] -> 116
thanks all
-rubynube
pseudo code:
word = "picture"
for( i = 0; i < word.length; i++ )
{
puts( word.substr(i,1) )
}
ruby?
I've tried something like:
word = "picture"
word.each { |char| puts char }
but that doesn't do what I am wanting. it ends up just putting the
entire word "picture"
I've also tried:
word = "picture"
for i in 0..word.length - 1
puts word
end
that just puts out ascii numbers..
I thought strings could be access like arrays?
word = "picture"
puts word[0] -> 116
thanks all
-rubynube