Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Clean up code examples (OCD)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Sep 27, 2012
1 parent 00a2a0a commit 90bc363
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions README.markdown
Expand Up @@ -37,9 +37,11 @@ You can use this in any place a block is expected, for example to create a lambd

Last but definitly not least you can use this as a target for `when` like this

case( something )
when X.respond_to? :foo then "something responds to :foo"
when X.kind_of? Hash then "something is a Hash"
case something
when X.respond_to? :foo
something.foo
when X.respond_to? :[]
something['foo']
end

Gotchas
Expand Down
8 changes: 5 additions & 3 deletions lib/ampex.rb
Expand Up @@ -25,9 +25,11 @@ def initialize(&block)

# This method is here so that a metavariable can be used as a target for "when" like this:
#
# case( foo )
# when X.respond_to? :bar then "Responds to :bar"
# when X.respond_to? :foobar then "Responds to :foobar"
# case foo
# when X.respond_to? :bar
# "Responds to :bar"
# when X.respond_to? :foobar
# "Responds to :foobar"
# end
#
def ===(y)
Expand Down

0 comments on commit 90bc363

Please sign in to comment.