I want to remove the attribute “prop” from all of them.
I tried it with this the first time:
a.collect {|x| y = x.to_a; y.delete(x.prop); y }
but it doesnt seem to work; i the property isn’t removed, and it would
also be bad if some other property would have the same value cause it
would get removed, too.
I´m sure there’s some a.without method or something, but I’m not able
to find it…
I want to remove the attribute “prop” from all of them.
That is not an attribute but a hash key.
I tried it with this the first time:
a.collect {|x| y = x.to_a; y.delete(x.prop); y }
but it doesnt seem to work; i the property isn’t removed, and it would
also be bad if some other property would have the same value cause it
would get removed, too.
I´m sure there’s some a.without method or something, but I’m not able
to find it…
aequivalent in ruby to get rid of it completely?
Not as far as I know in Ruby < 1.9
Ruby 1.9 has a private Object#remove_instance_variable method, but
unless you are using the defined? operator you really can’t tell
whether an instance variable exists since just referring to it creates
it if it doesn’t already exist.
On 11 Feb., 18:07, Robert K. [email protected] wrote:
only problem: The array actually consists of objects, I forgot.
So the code you showed is not the original code?
So they dont have the delete method.
I’ve now done this with x.dup.prop = nil; x but it seems a little
ugly to have that nil still in there.
I know, in PHP there is the unset function; is there somethin
aequivalent in ruby to get rid of it completely?
only problem: The array actually consists of objects, I forgot.
So they dont have the delete method.
I’ve now done this with x.dup.prop = nil; x but it seems a little
ugly to have that nil still in there.
I know, in PHP there is the unset function; is there somethin
aequivalent in ruby to get rid of it completely?