Last active
January 3, 2016 14:19
-
-
Save bartoszkopinski/8475901 to your computer and use it in GitHub Desktop.
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
class Symbol | |
def & s | |
:"#{self} #{s}" | |
end | |
def to_proc | |
proc do |v| | |
to_s.split.inject(v){ |val, m| val.send(m) } | |
end | |
end | |
end | |
[1, nil, 3.0, 'a'].map(&:to_i&:to_s&:to_f) | |
# => [1.0, 0.0, 3.0, 0.0] |
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
class Symbol | |
def method_missing s | |
:"#{self} #{s}" | |
end | |
def to_proc | |
proc do |v| | |
to_s.split.inject(v){ |val, m| val.send(m) } | |
end | |
end | |
end | |
[1, nil, 3.0, 'a'].map(&:to_i.to_f.zero?) | |
# => [false, true, false, true] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment