Page 1 of 1

help ruby

Posted: Thu Feb 28, 2013 8:17 pm
by mimine
just need to simply remove a line in the list array (ruby my nightmare) :cry:

Re: help ruby

Posted: Thu Feb 28, 2013 11:14 pm
by TrojakEW
Something like this?

Re: help ruby

Posted: Fri Mar 01, 2013 1:44 am
by trogluddite
And if you swap...
im.delete_at(<number>)
...which deletes at a soecific location.
...for...
im.delete(<string>)
You can delete an entry by its name; for example...
im.delete("lo")

Re: help ruby

Posted: Fri Mar 01, 2013 9:20 am
by mimine
thank you for the help. I changed a little, the entry number in array or text. this is exactly what I wanted. good job. ;)

Re: help ruby

Posted: Fri Mar 01, 2013 3:37 pm
by trogluddite
Great - glad it is now working.

A couple of little tips for the Ruby.

- The line with only "@ins[1]" is not required - using that value inside the "delete" or "delete_at" is enough to make Ruby read the value.

- When putting the values inside '(...)' it is better not to put a space between the method name and the values, e.g...
im.delete(@ins[1])
(no space follows 'delete')
Mostly, using a space is OK, but I have noticed that sometimes putting a space will give an error.