https://github.com/JuliaLang/julia/issues/6823 already proposed exactly this.
On Wed, Jun 8, 2016 at 8:22 AM, Anonymous <espr...@gmail.com> wrote: > That's a good idea. Yes because it's a bit confusing with the && since > that returns false with the condition isn't satisfied, while an if > statement would simply return nothing. > > On Wednesday, June 8, 2016 at 2:50:40 AM UTC-7, Mauro wrote: > >> On Wed, 2016-06-08 at 11:37, Patrick Kofod Mogensen < >> patrick....@gmail.com> wrote: >> > But that is exactly what Forgy's code does >> > >> > expression && do_something >> >> Problem with this is that it is a bit cryptic. >> >> There is this related issue: >> https://github.com/JuliaLang/julia/issues/16389 >> >> @Anonymous: why don't you post your suggestion there? Where it is more >> likely to get traction. >> >> > 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 >> >>> >> >> >> >