Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fronx/74500 to your computer and use it in GitHub Desktop.
Save fronx/74500 to your computer and use it in GitHub Desktop.
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