Created
March 5, 2009 19:18
-
-
Save fronx/74500 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 << self | |
def with(expression) | |
yield expression | |
end | |
end | |
# ----------------------------------------------------- | |
def really_long_and_very_complicated_expression | |
'quite long text ' * 400 | |
end | |
# ----------------------------------------------------- | |
def temp_var_way | |
x = really_long_and_very_complicated_expression | |
x.length > 255 ? x[0..252] + '...' : x | |
end | |
puts temp_var_way | |
# ----------------------------------------------------- | |
def alternative? | |
with really_long_and_very_complicated_expression do |x| | |
x.length > 255 ? x[0..252] + '...' : x | |
end | |
end | |
puts alternative? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment