'take' missing from Set?

Why does [Identity]Set not implement take?

hjh

I don’t know.

ST-80 just has remove that returns item.

[1,2,3].remove(2) == 2
[1,2,3].asSet.remove(2) == [1,3].asSet

Of course, ST won’t let you remove: from an Array…

take and remove in SC can be quite similar!

x = [1,2,3] ; y = [1,2,3]
[x.remove(2) == y.take(2), x == y]

Ps. Squeak take:

#(1 2 3 4 5) asSet remove: 2 "=> 2"
#(1 2 3 4 5) asSet take: 2 "=> a Set(1 2)"

I suspect that result is coincidental – remove preserves order but take is not guaranteed to.

But… interface confusion: Bag:take is a combination of choose and remove, while Array:take requires you to specify the item to take :confused: … That’s… odd.

Mainly I don’t see why Bag has this method and Set doesn’t… Isn’t a Set just a Bag that has only one of each item?

hjh