iseng
1
how do i unset a hash member (as in php)?
h[‘a’] = ‘aaa’
h[‘b’] = ‘bbb’
h[‘c’] = ‘ccc’
h >> { ‘a’ => ‘aaa’, ‘b’ => ‘bbb’, ‘c’ => ‘ccc’ }
something like this:
h[‘b’].delete
h >> { ‘a’ => ‘aaa’, ‘c’ => ‘ccc’ }
not like this:
h[‘b’] = nil
h >> { ‘a’ => ‘aaa’, ‘b’ => nil, ‘c’ => ‘ccc’ }
thanks. 
iseng
2
something like this:
h[‘b’].delete
h >> { ‘a’ => ‘aaa’, ‘c’ => ‘ccc’ }
C:\Documents and Settings\flifson>irb
irb(main):001:0> h={‘a’=>‘aaa’,‘b’=>‘bbb’}
=> {“a”=>“aaa”, “b”=>“bbb”}
irb(main):002:0> h.delete(‘b’)
=> “bbb”
irb(main):003:0> h
=> {“a”=>“aaa”}
irb(main):004:0>
iseng
3
On 7/3/06, aa bb [email protected] wrote:
how do i unset a hash member (as in php)?
Hash.delete(key)…
hsh = { ‘a’ => “test”, “b” => “testagain” }
hsh.delete(‘a’)
hsh is now {“b”=>“testagain”}
h[‘a’] = ‘aaa’
iseng
4
:o that easy? thanks.
i feel silly now.
how to do this with ruby on rails session? because it didn’t work.
session[‘a’] = 123
session.delete(‘a’) <<< error
i can do this though:
session.model.data.delete(‘a’) <<< it worked
there must be a better way?
iseng
5
On Jul 3, 2006, at 12:51 AM, aa bb wrote:
there must be a better way?
You’ll have to ask on the Rails mailing list.
http://lists.rubyonrails.org
–
Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant
http://trackmap.robotcoop.com