-
-
Save avdi/a6decb66f057d8120125 to your computer and use it in GitHub Desktop.
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