Skip to content

Commit

Permalink
Fix some markdown that github doesn't like
Browse files Browse the repository at this point in the history
  • Loading branch information
raganwald committed May 24, 2009
1 parent 8724d44 commit a2ba991
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 2008-10-29/kestrel.markdown
Expand Up @@ -52,7 +52,7 @@ It is obvious from the first line what will be returned and it eliminates an ann

**object initializer blocks**

The Kestrel has also been sighted in the form of *object initializer blocks*. Consider this example using [Struct](http://blog.grayproductions.net/articles/all_about_struct"All about Struct"):
The Kestrel has also been sighted in the form of *object initializer blocks*. Consider this example using [Struct](http://blog.grayproductions.net/articles/all_about_struct "All about Struct"):

Contact = Struct.new(:first, :last, :email) do
def to_hash
Expand Down
2 changes: 1 addition & 1 deletion 2008-10-30/thrush.markdown
Expand Up @@ -75,7 +75,7 @@ Much better, Ruby 1.9 creates a new scope inside the block and `x` is local to t
# ...
end

`let` creates a new scope and defines your block local variable inside the block. This [signals](http://weblog.raganwald.com/2007/11/programming-conventions-as-signals.html"Programming conventions as signals") that the block local variable is not used elsewhere. Imperative methods can be easier to understand when they are composed of smaller blocks with well-defined dependencies between them. A variable local to the entire method creates a dependency across the entire method. A variable local to a block only creates dependencies within that block.
`let` creates a new scope and defines your block local variable inside the block. This [signals](http://weblog.raganwald.com/2007/11/programming-conventions-as-signals.html "Programming conventions as signals") that the block local variable is not used elsewhere. Imperative methods can be easier to understand when they are composed of smaller blocks with well-defined dependencies between them. A variable local to the entire method creates a dependency across the entire method. A variable local to a block only creates dependencies within that block.

Although Ruby 1.8 does not enforce this behaviour, it can be useful to write code in this style as a signal to make the code easier to read.

Expand Down
2 changes: 1 addition & 1 deletion 2008-10-31/songs_of_the_cardinal.markdown
Expand Up @@ -39,7 +39,7 @@ Now, this bizarre syntactic convention of writing `foo.call(bar).call(bash)` is

**Let's build a cardinal in Ruby**

The next chunk of code works around the fact that Ruby 1.8 can't define a proc that takes a block and also doesn't allow `define_method` to define a method that takes a block. So for Ruby 1.8, we will start by making a utility method that defines methods that can take a block, based on [an idea from coderr](http://coderrr.wordpress.com/2008/10/29/using-define_method-with-blocks-in-ruby-18/"Using define_method with blocks in Ruby 1.8"). For Ruby 1.9 this is not necessary, you can use `define_method` to define methods that take blocks as arguments.
The next chunk of code works around the fact that Ruby 1.8 can't define a proc that takes a block and also doesn't allow `define_method` to define a method that takes a block. So for Ruby 1.8, we will start by making a utility method that defines methods that can take a block, based on [an idea from coderr](http://coderrr.wordpress.com/2008/10/29/using-define_method-with-blocks-in-ruby-18/ "Using define_method with blocks in Ruby 1.8"). For Ruby 1.9 this is not necessary, you can use `define_method` to define methods that take blocks as arguments.

def define_method_taking_block(name, method_body_proc)
self.class.send :define_method, "__cardinal_helper_#{name}__", &method_body_proc
Expand Down
4 changes: 2 additions & 2 deletions 2008-11-12/the_obdurate_kestrel.md
Expand Up @@ -8,7 +8,7 @@ The Enchaining Kestrel

In [Kestrels](http://github.com/raganwald/homoiconic/tree/master/2008-10-29/kestrel.markdown#readme), we looked at `#tap` from Ruby 1.9 and `returning` from Ruby on Rails. Today we're going to look at another use for `tap`.

[![Kestrel Composite (c) 2007 Mark Kilner](http://farm3.static.flickr.com/2165/1902016010_6f007bf3f0.jpg)](http://flickr.com/photos/markkilner/1902016010/"Kestrel Composite (c) 2007 Mark Kilner")
[![Kestrel Composite (c) 2007 Mark Kilner](http://farm3.static.flickr.com/2165/1902016010_6f007bf3f0.jpg)](http://flickr.com/photos/markkilner/1902016010/ "Kestrel Composite (c) 2007 Mark Kilner")

As already explained, Ruby 1.9 includes the new method `Object#tap`. It passes the receiver to a block, then returns the receiver no matter what the block contains. The canonical example inserts some logging in the middle of a chain of method invocations:

Expand Down Expand Up @@ -85,7 +85,7 @@ So there's another use for `#tap` (along with `Symbol#to_proc` for simple cases)
The Obdurate Kestrel
---

[![Kestrel (c) 2007 The Hounds of Shadow](http://farm3.static.flickr.com/2402/2115973156_f4fcfca811.jpg)](http://flickr.com/photos/thehoundsofshadow/2115973156/"Kestrel (c) 2007 The Hounds of Shadow")
[![Kestrel (c) 2007 The Hounds of Shadow](http://farm3.static.flickr.com/2402/2115973156_f4fcfca811.jpg)](http://flickr.com/photos/thehoundsofshadow/2115973156/ "Kestrel (c) 2007 The Hounds of Shadow")

The [andand gem](http://github.com/raganwald/andand/tree "raganwald's andand") includes `Object#tap` for Ruby 1.8. It also includes another kestrel called `#dont`. Which does what it says, or rather *doesn't* do what it says.

Expand Down

0 comments on commit a2ba991

Please sign in to comment.