apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
_whitelogger has joined #ruby
<apeiros_>
kah1: instead, you probably want: array1 = [] # <-- that assigns a new array, leaving the old one that you pushed to chapters untouched
<kah1>
apeiros_: ah! ok ok, i'll try that!
<apeiros_>
kah1: also `chapters = chapters.push array1` - don't do that. `chapters.push array1` is sufficient. (push modifies the array, it does not return a new, modified array)
<kah1>
apeiros_: dude, thanks so much
<apeiros_>
I also strongly suggest using a proper class. for what you're currently doing, a struct would suffice.
gregorg_taf has joined #ruby
<kah1>
a what would suffice?
<apeiros_>
a struct. give me a minute…
<kah1>
apeiros_: cool thanks.
<apeiros_>
you don't need ch_count either, you can ask the array for its size
<kah1>
apeiros_: really that's cool
<kah1>
really? *
<apeiros_>
kah1: http://pastie.org/3663156 - there's more that could be changed. I tried not to change too much at once, so you can still track the changes.
statarb3 has joined #ruby
<apeiros_>
oh, I made a small mistake, sorry, I'll paste again…
<apeiros_>
reload, I fixed the bug.
<apeiros_>
gah, second bug…
<kah1>
apeiros_: dude that's fockin amazing!
<Tomasso>
how do you get the current index when iterating on a collection? elem.key doesnt work
<apeiros_>
meh, too many mistakes
<apeiros_>
kah1: wait a minute, I'll remove the stupidities and repaste…
<apeiros_>
Tomasso: how should elem.key work… elem is just the element, it has no idea it is in an array (could even be in multiple, what'd .key return then?)