Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Don't Get Clever

avdi
July 20, 2013
290

Don't Get Clever

Part of the Ruby Rogues live panel episode at Lone Star Ruby Conference 2013.

avdi

July 20, 2013
Tweet

Transcript

  1. Don't Get Clever
    Avdi Grimm

    View full-size slide

  2. Pop quiz
    r
    e
    q
    u
    i
    r
    e '
    p
    s
    t
    o
    r
    e
    '
    s
    t
    o
    r
    e = P
    S
    t
    o
    r
    e
    .
    n
    e
    w
    (
    '
    d
    a
    t
    a
    .
    p
    s
    t
    o
    r
    e
    '
    )
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    t
    r
    u
    e
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View full-size slide

  3. Pop quiz 2
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    f
    a
    l
    s
    e
    )

    View full-size slide

  4. Symbols are truthy
    r
    e
    q
    u
    i
    r
    e '
    p
    s
    t
    o
    r
    e
    '
    s
    t
    o
    r
    e = P
    S
    t
    o
    r
    e
    .
    n
    e
    w
    (
    '
    d
    a
    t
    a
    .
    p
    s
    t
    o
    r
    e
    '
    )
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    :
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View full-size slide

  5. What's :
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ??
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    :
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View full-size slide

  6. Dead end
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    :
    c
    h
    u
    n
    k
    y
    _
    b
    a
    c
    o
    n
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View full-size slide

  7. Negation
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    !
    :
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r
    )

    View full-size slide

  8. Don't get clever

    View full-size slide

  9. Intention-revealing argument
    r
    e
    a
    d
    _
    o
    n
    l
    y = t
    r
    u
    e
    s
    t
    o
    r
    e
    .
    t
    r
    a
    n
    s
    a
    c
    t
    i
    o
    n
    (
    r
    e
    a
    d
    _
    o
    n
    l
    y
    ) d
    o
    # .
    .
    .
    e
    n
    d

    View full-size slide

  10. Intention-revealing argument
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r = f
    a
    l
    s
    e
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r
    )

    View full-size slide

  11. Inline version
    A
    r
    r
    a
    y
    .
    i
    n
    s
    t
    a
    n
    c
    e
    _
    m
    e
    t
    h
    o
    d
    s
    (
    i
    n
    c
    l
    u
    d
    e
    _
    s
    u
    p
    e
    r = f
    a
    l
    s
    e
    )

    View full-size slide

  12. Don't get clever

    View full-size slide