Does the set of all sets contain itself?

April 3, 2012 Pivotal Labs

No.

$ irb -r set
1.9.3p125 :001 > set = ObjectSpace.each_object(Set).to_set
 => #<Set: {#<Set: {...}>}>
1.9.3p125 :002 > set.include?(set)
 => false

However, the Enumeration of all Enumerations does contain itself.

1.9.3p125 :001 > e = ObjectSpace.each_object(Enumerator)
 => #<Enumerator: ObjectSpace:each_object(Enumerator)>
1.9.3p125 :002 > e.include?(e)
 => true

Why this is so is left as an exercise to the reader.

About the Author

Biography

More Content by Pivotal Labs
Previous
Responsive Web Design From The Future
Responsive Web Design From The Future

Responsive web design is about a lot more than the size of your screen. Kyle Neath, Director of Design for ...

Next
Responsive Web Design
Responsive Web Design

Kyle Neath talks about responsive web design.… Read more

Enter curious. Exit smarter.

Register Now