Permalink
Browse files

Update block argument docs for pattern-match

  • Loading branch information...
cvb committed Sep 24, 2015
1 parent 8154e69 commit ccda8a7bb0484d783d73244208ceebe1f28d9df4
Showing with 11 additions and 11 deletions.
  1. +11 −11 doc/pattern_matching.md
View
@@ -214,8 +214,8 @@
Ruby:
```ruby
defn(:old_enough, _){ true }.when{|x| x >= 16 }
defn(:old_enough, _){ false }
defn(:old_enough, _){ |_| true }.when{|x| x >= 16 }
defn(:old_enough, _){ |_| false }
```
##### Order Matters
@@ -382,7 +382,7 @@
must appear AFTER the prior match or it will override that one
f
}
defn(:hashable, {}) { ||
defn(:hashable, {}) { |_|
matches an empty hash
:empty
}
@@ -411,10 +411,10 @@
defn(:all, :one, Integer, ALL) { |int, args|
[int, args]
}
defn(:all, 1, _, ALL) { |var, args|
defn(:all, 1, _, ALL) { |var, _, *args|
[var, args]
}
defn(:all, ALL) { | args|
defn(:all, ALL) { |*args|
args
}
@@ -450,22 +450,22 @@
```
```ruby
defn(:old_enough, _){ true }.when{|x| x >= 16 }
defn(:old_enough, _){ false }
defn(:old_enough, _){ |_| true }.when{|x| x >= 16 }
defn(:old_enough, _){ |_| false }
defn(:right_age, _) {
defn(:right_age, _) { |_|
true
}.when{|x| x >= 16 && x <= 104 }
defn(:right_age, _) {
defn(:right_age, _) { |_|
false
}
defn(:wrong_age, _) {
defn(:wrong_age, _) { |_|
false
}.when{|x| x < 16 || x > 104 }
defn(:wrong_age, _) {
defn(:wrong_age, _) { |_|
true
}
```

0 comments on commit ccda8a7

Please sign in to comment.