Nils and method chaining

后端 未结 9 2467
忘了有多久
忘了有多久 2021-02-14 19:21

I\'m just breaking into the ruby world and I could use a helping hand.

Suppose b is nil.

I\'d like the following code to return n

9条回答
  •  醉梦人生
    2021-02-14 19:44

    I think you can find a great solution in rails but that solution follows a different approach. Take a look at the try method. It's a clean approach.

提交回复
热议问题