Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3248

Re: Can I check contain value in hash?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: Can I check contain value in hash?
Date Wed, 20 Apr 2011 10:25:39 -0500
Organization Service de news de lacave.net
Lines 46
Message-ID <d06a4768babf4824899a76c5167f174f@ruby-forum.com> (permalink)
References <4c6b84f27beab6e6f15f2d315a4bef87@ruby-forum.com> <BANLkTinHV63ORGKHVBwp2NwBicfUmW6Nwg@mail.gmail.com> <eb48768a2329cb68d8a781177e83fd01@ruby-forum.com> <BANLkTi=u-iEduLvX=bRBC2-ATA69kWi8QA@mail.gmail.com>
NNTP-Posting-Host bristol.highgroove.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace talisker.lacave.net 1303313176 1994 65.111.164.187 (20 Apr 2011 15:26:16 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Wed, 20 Apr 2011 15:26:16 +0000 (UTC)
In-Reply-To <BANLkTi=u-iEduLvX=bRBC2-ATA69kWi8QA@mail.gmail.com>
X-Received-From This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway
X-Mail-Count 381929
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <d06a4768babf4824899a76c5167f174f@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:3248

Show key headers only | View raw


Robert K. wrote in post #993961:
> My first choice would be to use Set and not Hash as values.

OK, although Set is really just a thin wrapper around Hash(*), and I 
find it easier to work with objects of one class instead of a two.

Regards,

Brian.

(*) example methods from class Set:

  def size
    @hash.size
  end

  def empty?
    @hash.empty?
  end

  def clear
    @hash.clear
    self
  end

  def to_a
    @hash.keys
  end

  def include?(o)
    @hash.include?(o)
  end

  def add(o)
    @hash[o] = true
    self
  end

  def delete(o)
    @hash.delete(o)
    self
  end

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Can I check contain value in hash? Siratinee Sukachai <ploy.sukachai@gmail.com> - 2011-04-19 23:02 -0500
  Re: Can I check contain value in hash? Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-20 02:49 -0500
    Re: Can I check contain value in hash? Brian Candler <b.candler@pobox.com> - 2011-04-20 03:33 -0500
      Re: Can I check contain value in hash? Robert Klemme <shortcutter@googlemail.com> - 2011-04-20 03:50 -0500
        Re: Can I check contain value in hash? Brian Candler <b.candler@pobox.com> - 2011-04-20 10:25 -0500
          Re: Can I check contain value in hash? Robert Klemme <shortcutter@googlemail.com> - 2011-04-21 02:12 -0500

csiph-web