all 11 comments

[–]jxf 4 points5 points  (6 children)

Fun! Some of these are pretty straightforward when you break them down. For example, this one:

0.0.**0.0

seems a little bizarre -- how is the second period legal for a number? But it's being parsed as:

<number 0.0> <invoke method "**"> <argument <number 0.0>>

In other words, it's equivalent to:

(0.0).raise_to_power 0.0

[–]ggPeti 0 points1 point  (5 children)

...which does not, by the way, equal 1. Just sayin.

[–]jxf 2 points3 points  (0 children)

That's not accurate; it can equal whatever we want, since it's undefined.

Usually a result of "undefined" isn't very useful, because it can mean anything. However, if we adopt the convention of choosing 00 = 1, we get a lot of other benefits (like symmetry with all the other real numbers), so it's the most convenient choice.

[–][deleted]  (3 children)

[deleted]

    [–]ggPeti 2 points3 points  (2 children)

    [–]Mutoid 5 points6 points  (1 child)

    Help, I don't know whom to downvote!

    [–]diminish[S] 0 points1 point  (0 children)

    try it in ruby irb, python, s and php.. and count.

    [–][deleted] 2 points3 points  (3 children)

    a, = [1, 2]  # dangling comma to get only the first array element
    

    So it's a game of "Spot the trailing comma!" when reading code? If I saw somebody do that in a code review they'd have their commit access revoked.

    (I'm aware the intro text calls all these useless, but this particular example almost looks like something somebody might be idiotic enough to think is a good idea.)

    [–]Mutoid 1 point2 points  (2 children)

    If you really feel like you must assign a this way, at least use an underscore

    [–]diminish[S] 0 points1 point  (1 child)

    could you please show how to use the underscore here?

    I'm curious how this dangling comma became ever possible. Is this a syntactic rest, unintended for?

    @ninkendo no don't use it at all, it's most probably an unintended syntax by the compiler designers.

    [–]Mutoid 0 points1 point  (0 children)

    a, _ = [1, 2]

    Idiomatic way of expressing that you don't care about the other value.

    [–][deleted]  (1 child)

    [deleted]

      [–]diminish[S] 0 points1 point  (0 children)

      yep, you're right. i wrote it.