Created
July 26, 2014 03:48
-
-
Save havenwood/80f2724eccd35a65257c to your computer and use it in GitHub Desktop.
An EqualizableStruct with Equalizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'equalizer' | |
class EqualizableStruct < Struct | |
def initialize *args, &block | |
class << self | |
include Equalizer.new(*members) | |
end | |
super | |
end | |
end | |
Point = EqualizableStruct.new(:x, :y) | |
Point.new(0, 0) == Point.new(0, 0) | |
#=> true | |
Point.new(0, 0) == Point.new(1, 1) | |
#=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment