I always just read them like this:

cond "and" do_something
cond "or" do_something


That seems like it reads pretty naturally to me. This is also one of the
reasons I've occasionally brought up the idea of having "and" and "or"
keywords.


On Thu, Mar 20, 2014 at 5:27 PM, Leah Hanson <astriea...@gmail.com> wrote:

> I'm not so sure about i == 1 && do_stuff() being readable, but I think
> it's better than do_stuff() if i==1. Every time I see i==1 && do_stuff(), I
> have to stop and reason about what it's doing, but at least it isn't
> tricky. With && either you can read it easily, or you see that something
> weird is going on; with end of line if's, it's always this surprising thing
> where you need to reconsider the preceding part of the line (which makes it
> much more appealing for the person *writing* the code than the one
> *reading* it.
>
> -- Leah
>
>
> On Thu, Mar 20, 2014 at 4:16 PM, Jacob Quinn <quinn.jac...@gmail.com>wrote:
>
>> I agree. I've never liked python's do_stuff() if i == 1. It's too
>> disconcerting to parse what's going on and then have to backtrack and think
>> about the condition that came afterwards. I've found the i == 1 &&
>> do_stuff() has become really natural after only using it a few times.
>>
>> -Jacob
>>
>>
>> On Thu, Mar 20, 2014 at 5:13 PM, Ivar Nesje <iva...@gmail.com> wrote:
>>
>>> The suffix `if` and `unless` is the reason I never managed to become
>>> literate in Ruby. Maybe it is just a matter of time and experience, but I
>>> read code lines from left to right, and my mental read buffer is not long
>>> enough to see the `if` that someone hid at the end of the line.
>>>
>>
>>
>

Reply via email to