I have hash which is contain list of string value.
I need to check is the value already contained in the key.
Add add the value to the key if the key is not contained that value.
Can I do that?
Although if your arrays can grow and so you are checking include? many
times on big arrays, you might want to use a Set instead of an Array.
Jesus.
···
On Wed, Apr 20, 2011 at 6:02 AM, Siratinee Sukachai <ploy.sukachai@gmail.com> wrote:
I have hash which is contain list of string value.
I need to check is the value already contained in the key.
Add add the value to the key if the key is not contained that value.
Can I do that?
In this case the difference is probably rather small but generally I
try to use the best abstraction. In this case "a collection which
contains every element at most once" translates directly to "set" for
me.
Kind regards
robert
···
On Wed, Apr 20, 2011 at 5:25 PM, Brian Candler <b.candler@pobox.com> wrote:
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.