Midwest Dev Chat

MidwestDevChat.com github.com/skidvis/Midwest-Dev-Chat

  • The newest 15 messages in the super-cool #ruby channel.

  • 05/11 12:12:05 Frederik: o_o;;;

  • 05/11 12:31:42 Frederik: because of this article now I am learning things: https://en.wikipedia.org/wiki/Non-English-based_programming_languages

  • 05/16 16:19:31 Hollie: Is there any reason to use Rails’ `Object.try` in a world with the safe navigation operator?

  • 05/16 16:59:44 Jaycee: I can't promise I'll try. But I'll try to try. -- Homer Simpson

  • 05/17 08:52:01 Norbert: If you’ve backed yourself into enough of a corner that you need to chain two attempts one will behave more strictly and the other won’t
    e.g. `foo.try(:bar).try(:baz)` where bar can return false gets you `nil` whereas `foo&.bar&.baz` get you

    undefined method `baz` for false:FalseClass

  • 05/17 08:52:25 Norbert: Good detailed write up here: http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/

  • 05/17 08:54:24 Norbert: TIL there’s a `try!` bang method and of the `dig` method of traversing hashes in Ruby 2.3.x

  • 05/18 09:26:29 Frederik: +1 for `dig`

  • 05/18 17:32:41 Emmett: has joined the channel

  • 05/22 15:31:33 Eusebio: `try` is still useful when you know the receiver is not `nil` but don’t know if it has a certain method and you don’t really care. It’s much shorter than using `receiver.method if receiver.responds_to?(:method)`

  • 05/22 15:34:11 Eusebio: or if the method sometimes throws an error and, again, you don’t really care to do anything different in that scenario

  • 05/23 08:55:38 Sarai: has joined the channel

  • 05/23 12:29:06 Hollie: @Eusebio I don’t get why you’d use `try` for a method that might throw an error. It looks from the source that `try` will not prevent a method that exists from raising that error.
    But I took your second statement to mean that you could use `try` to swallow an error and move on if you don’t care to handle it. Is that different from what you were saying?

  • 05/23 12:31:33 Eusebio: oh, ha. I guess I thought `try` suppresses errors but indeed it does not. clearly I haven't used it that way.

  • 05/23 12:33:07 Eusebio: but still good for non-nil receivers that "might" have a given method (like an optional interface)

  • *Usernames have been changed to protect the innocent.

Check out all the cool channels!

Join the conversation!