Sha256: e947297bc5c04467b1df389fe6d2718a4458c6eb4f9a46dac82892e79caa4a18

Contents?: true

Size: 534 Bytes

Versions: 6

Compression:

Stored size: 534 Bytes

Contents

require "patternmatching"

include PatternMatching

class Foo 
  def initialize
    @name = "Foo"
  end
  attr :name
  def foo
  end

  def bar
    make "bar" do
      seems as {:val} do
        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 
    the.name = val
    this
  end
end

o = Foo.new
p o.bar == o #=> true 
p o.name #=> "bar"
p o.buzz("buzz") == o #=> true
p o.name #=> "buzz"

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
patternmatching-0.2.1 examples/match_inside_class.rb
patternmatching-0.2.4 examples/match_inside_class.rb
patternmatching-0.2.3 examples/match_inside_class.rb
patternmatching-0.2.0 examples/match_inside_class.rb
patternmatching-0.2.2 examples/match_inside_class.rb
patternmatching-0.2.5 examples/match_inside_class.rb