Permalink
Browse files

Added missing literal types to Chapter03

  • Loading branch information...
1 parent da430ef commit f8eb51a4b22b5031b74a3a930b075489d690bf5c @bakkdoor bakkdoor committed Feb 16, 2011
Showing with 25 additions and 0 deletions.
  1. +25 −0 Chapter03.md
View
25 Chapter03.md
@@ -109,7 +109,32 @@ We've seen Blocks in Chapter 1 before, but for completeness, here's a list of so
# Seperating arguments with comma is optional, thus this is valid as well:
|x, y| { "The sum is: #{x + y}" println }
+There's also *Partial Blocks* which can be used for Blocks only taking
+one argument:
+
+ @{ + 1 } # is the same as: |x| { x + 1 }
+ # e.g.:
+ [1,2,3,4] map: @{+ 1} # => [2,3,4,5]
+
To `call` a Block, you send it the `call` or `call:` message and pass the arguments in as an Array:
block = |x, y| { x + y println }
block call: [2, 3] # will print 5
+
+## 3.8 Regular Expressions ##
+
+Fancy, as Ruby or Perl, has Regular Expressions built-in to the
+language. In fact, it uses the same implementation that Ruby uses on
+top of Rubinius, including the same literal syntax:
+
+ /^Hello, (.*)!$/
+ /^[A-Z][a-Z0-9_:]$/
+
+
+## 3.9 Ranges ##
+
+Fancy also has Ranges, like Ruby:
+
+ (1..10)
+ (a..b)
+ (x .. x ** x)

0 comments on commit f8eb51a

Please sign in to comment.