Page 1 of 1

Splitting\appending arrays with ruby

Posted: Sat May 28, 2016 6:22 pm
by kortezzzz
This topic started in other post and has been answered by @tulamide, but since I had no luck to write the code correctly, I would love if you ruby gurus please tell me whats wrong. Uploaded a simple schematic that partly works, so all is needed here is a little fix so the whole forum (even the bad coders, like me) would enjoys those must have features.

As you would see, my "split" code cuts the array from the end, not from the beginning, as the green does, so I used simple math to fix it, but I'm sure the whole thing can be done simply in ruby itself.

My "append" code shows an error (although tulamide mentioned that there is no meaning to the array's type, so why?)

Re: Splitting\appending arrays with ruby

Posted: Sat May 28, 2016 8:26 pm
by tulamide
Read the error message. You're trying to convert nil to a string. Nil means, there is no object, and I hope you'll agree that you can't convert a big hole of nothing into a string ;)

Re: Splitting\appending arrays with ruby

Posted: Sun May 29, 2016 1:09 pm
by kortezzzz
Thanks for the fix, tulamide. the concepts now work :)