More elegant way to write this?
Posted
by tesmar
on Stack Overflow
See other posts from Stack Overflow
or by tesmar
Published on 2010-05-18T04:11:32Z
Indexed on
2010/05/18
4:20 UTC
Read the original article
Hit count: 273
Hi,
I am trying to make a multi-dimensional array of characters in ruby, and this works, but is there a more elegant way?
def initialize(text)
@map = Array.new
i = 0
text.split("\n").each do |x|
@map[i] = x.scan(/./)
i += 1
end
#@map = text
end#constructor
© Stack Overflow or respective owner