P
Peter v. N.
Hi all,
Once again I disturb you for a, maybe, obvious thing
I can't figure out.
I have successfully created an md array (see older posts
from me) thanks to the support found here.
Now I would like to list all String items in the source array
(a Text file containing numbers) and convert and place them into the
destination array as int objs. I know about the String#split method but
this recreates an array that does not match the dimensions I want
(e.g. lines with different length).
My approach is very c-ish:
<code>
# @source is a String array. If the string contains a non-convertible
# substring, 0 is placed in destination array. @array is the destination
# md array created with the appropriate dimensions according to @source
# (longest line as vindex (-) and index as hindex (|) )
for i in (e-mail address removed)
for j in 0...@vindex.length
@array[j] = @source[j].to_i.char.to_i
end
end
</code>
Is there a Ruby way to replace <code> with blocks?
Thank you very much for a hint.
Brgds,
Peter
Once again I disturb you for a, maybe, obvious thing
I can't figure out.
I have successfully created an md array (see older posts
from me) thanks to the support found here.
Now I would like to list all String items in the source array
(a Text file containing numbers) and convert and place them into the
destination array as int objs. I know about the String#split method but
this recreates an array that does not match the dimensions I want
(e.g. lines with different length).
My approach is very c-ish:
<code>
# @source is a String array. If the string contains a non-convertible
# substring, 0 is placed in destination array. @array is the destination
# md array created with the appropriate dimensions according to @source
# (longest line as vindex (-) and index as hindex (|) )
for i in (e-mail address removed)
for j in 0...@vindex.length
@array[j] = @source[j].to_i.char.to_i
end
end
</code>
Is there a Ruby way to replace <code> with blocks?
Thank you very much for a hint.
Brgds,
Peter