Skip to content

Instantly share code, notes, and snippets.

/eq.pl6 Secret

Created September 7, 2016 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/82e9f1fc92de6e4e40ff463612e10e69 to your computer and use it in GitHub Desktop.
Save anonymous/82e9f1fc92de6e4e40ff463612e10e69 to your computer and use it in GitHub Desktop.
obj equi
#!/usr/bin/env perl6
class Foo {
has Str $.a;
has Int $.b;
method eq(Foo $other){
my Bool $flag = True;
for self.^attributes {
do { $flag = False; last; } unless ( $_.get_value(self).Str eq $_.get_value($other).Str );
}
return $flag;
}
}
say Foo.new(:a(<foo>), b => 100).eq(Foo.new(:a(<foo>), b => 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment