Class: Set

Inherits:
Object
  • Object
show all
Defined in:
lib/axiom_of_choice.rb

Instance Method Summary collapse

Instance Method Details

#pickObject

Picks an arbitrary element from the set and returns it. Use pop to pick and delete simultaneously.



5
6
7
# File 'lib/axiom_of_choice.rb', line 5

def pick
  @hash.first.first
end

#popObject

Picks an arbitrary element from the set and deletes it. Use pick to pick without deletion.



11
12
13
14
15
# File 'lib/axiom_of_choice.rb', line 11

def pop
  key = pick
  @hash.delete(key)
  key
end