But that is exactly what Forgy's code does

expression && do_something 

is the same as

if expression
do_something
end

On Wednesday, June 8, 2016 at 10:44:18 AM UTC+2, Anonymous wrote:
>
> I think maybe I didn't write exactly what I meant to.  The expression in 
> my original post should have been a boolean value,  I want to mimic an if 
> statement basically.  Something of the form:
>
> boolean ? expression_to_eval_if_boolean_is_true
>
> Since the ternary operator mimics an if-else statement, it seems strange 
> that you're given a convenient one-line form for an if-else statement, but 
> not for just a straight if statement.  Of course you could do
>
> if boolean; expression_to_eval_if_boolean_is_true; end
>
> but that's a bit clunky compared to the much slicker question-mark syntax.
>
> On Wednesday, June 8, 2016 at 1:11:29 AM UTC-7, Eric Forgy wrote:
>>
>> This is already available using '&&'
>>
>> expression && do_something
>>
>

Reply via email to