Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Changed Hash#delete / #default behaviour ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
"dooby" <dooby@d10.karoo.  
View profile  
 More options Feb 2 2003, 5:41 pm
Newsgroups: comp.lang.ruby
From: "dooby" <do...@d10.karoo.</SPAM>co.uk>
Date: Sun, 2 Feb 2003 22:34:30 -0000
Local: Sun, Feb 2 2003 5:34 pm
Subject: Changed Hash#delete / #default behaviour ?

Hi,

Should Hash#delete and Hash#[] give differing results when a
default is given ?

puts "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"

hsh = {'a' => 1}
hsh.default='missing'

puts hsh['a']
puts hsh.delete('a')
puts hsh['b']
puts hsh.delete('b')

# ruby 1.6.7 (2002-03-01) [i586-mswin32]
# 1
# 1
# missing
# missing

# ruby 1.7.3 (2002-11-17) [i386-mswin32]
# 1
# 1
# missing
# nil

IMO the previous behaviour was more useful when using #delete to select
an entry for once-only processing with a dummy object in the default
slot.
Better than: hsh.delete('b') || 'missing'.

(I'll add to the Pickaxe-update wiki if this change was intentional.)

Regards,

daz


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »