Sha256: b5023164de053a2ea95dc1de6229b0daf6bd4e52e5b43b73bd38f259ff2c5d08

Contents?: true

Size: 463 Bytes

Versions: 2

Compression:

Stored size: 463 Bytes

Contents

require "patternmatching"

# You can use local variables or methods inside builder 
val = 200
code = PatternMatching.build {plus(mul(100, 100), val)}

# Another partial style method example
class CalcX
  extend PatternMatching

  func(:calcx) do
    seems as {plus(:a, :b)} do
      calcx(a) + calcx(b)
    end
    seems as {mul(:a, :b)} do
      calcx(a) * calcx(b)
    end
  end
  func(:calcx).seems as {:value} do
    value
  end
end

p CalcX.new.calcx(code)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
patternmatching-0.2.4 examples/partial_style_method2.rb
patternmatching-0.2.5 examples/partial_style_method2.rb