Sha256: 83e03123a15b943c609e3cd750132ce02f79836584b6ee07b998b27e4eb875aa

Contents?: true

Size: 384 Bytes

Versions: 11

Compression:

Stored size: 384 Bytes

Contents

require "patternmatching"

include PatternMatching

class Person
  def initialize(name, age)
    @name = name
    @age = age
  end
  attr :name
  attr :age
end

# Example for matching Object except Hash
person = Person.new("Jiro", 3) 
make person do
  seems as {{:name => :name}} do
    puts "He is " + name
  end
  seems something do
    puts "no name"
  end
end # => "He is Jiro"

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
patternmatching-0.1.0 examples/object_matching.rb
patternmatching-0.1.3 examples/object_matching.rb
patternmatching-0.2.0 examples/object_matching.rb
patternmatching-0.2.3 examples/object_matching.rb
patternmatching-0.2.5 examples/object_matching.rb
patternmatching-0.1.1 examples/object_matching.rb
patternmatching-0.1.2 examples/object_matching.rb
patternmatching-0.2.1 examples/object_matching.rb
patternmatching-0.2.2 examples/object_matching.rb
patternmatching-0.1.4 examples/object_matching.rb
patternmatching-0.2.4 examples/object_matching.rb