examples/match_inside_class.rb in patternmatching-0.1.4 vs examples/match_inside_class.rb in patternmatching-0.2.0
- old
+ new
@@ -5,24 +5,31 @@
class Foo
def initialize
@name = "Foo"
end
attr :name
+ def foo
+ end
def bar
make "bar" do
seems as {:val} do
- @name = val
+ foo
+ # To access fields like this.name or this.name = ...
+ the.name = val
+ # To access self as this
+ this
end
end
end
func(:buzz).seems as {:val} do
- @name = val
+ the.name = val
+ this
end
end
o = Foo.new
-o.bar
+p o.bar == o #=> true
p o.name #=> "bar"
-o.buzz("buzz")
+p o.buzz("buzz") == o #=> true
p o.name #=> "buzz"