ruby - Is there a more rubylike way to do output_val = [ input_val, max ].min? -
Sometimes I need to do something like this:
output_val = (input_val & Lt; max)? Input_value: Max And if I'm stingy on space, then I can choose the option of:
output_val = [input_val, max]. Min Is there a short choice without sacrificing the expression?
Monkey Patch! For example: example:
133.Anless_over (100) # = & gt; 100 133. Nails_Over (150) # = & gt; 133 Note: I will not actually not this (I'll use your second example), but I'm guessing that this is a sense of question.
Comments
Post a Comment