This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Premise: a chainable DSL where evaluating a section in an if statement calls valid? | |
# Example: Each item changes the current synonym, it tests it against | |
class Moggy | |
SYNONYMS = [:cat, :moggy, :pussycat, :feline] | |
def set(syn) | |
@synonym = syn | |
self | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"fish" =~ /ish/ | |
"fish" !=~ /ish/ | |
!("fish" =~ /ish/) # equivalent to "fish" !~ /ish/ - thanks @MrJaba and @kerryb! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo | |
raise "I iz a fool" | |
"But you don't know, man" | |
rescue Exception => e | |
"I caught your foolness" | |
ensure | |
"and I returned you a fish" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby | |
class Rubyish | |
def a_method(some_string, some_hash) | |
@message = some_string | |
@transform = some_hash | |
puts @message | |
end | |
def another_method | |
@transform.each_pair do |key, val| |
NewerOlder