W1siziisijiwmtuvmdivmtivmtyvmzyvmdqvnteyl0f2yxrhci5wbmcixsxbinailcj0ahvtyiisijmwmhgzmdajil1d?sha=40d429a2ffd553af
In reply to: pants.halfbyte.org/ivo720
I know this is beside the point you are trying to make, but I really really like the ternary operator and find it very easy to read.

Clever or unreadable?

The most programming languages have some variation on C’s ternary operator:

1a = flag_is_set ? 23 : 42

While it is not very readable, it is compact and the meaning is clear to everyone who saw this thing before.

I know this is beside the point you are trying to make, but I really really like the ternary operator and find it very easy to read. Mostly because it simplifies the expression making it much easier to grasp what is going on.

Replies

Same here.

Clever or unreadable?

The most programming languages have some variation on C’s ternary operator:

1a = flag_is_set ? 23 : 42

While it is not very readable, it is compact and the meaning is clear to everyone who saw this thing before.

I know this is beside the point you are trying to make, but I really really like the ternary operator and find it very easy to read. Mostly because it simplifies the expression making it much easier to grasp what is going on.

Same here. Even though i don’t use it often in Ruby.

    I think the readability of the ternary varies very strongly with what you’re trying to achieve.

    I think the readability of the ternary varies very strongly with what you’re trying to achieve. I’ve seen completely unreadable ternary expressions, but then again, ugly code is almost always easy to write.

    Me personally, I have no problems parsing the ternary as well, but then again, I wrote my first line of C in probably 1994 or so. But it does not parse as easy for newcomers and takes a while to get used to.

    (why on earth did my pants not register that reply?)

      August 21, 2015 20:45 (via webmention)
      August 21, 2015 20:47 (via webmention)
      This document is webmention enabled.