Is it good style to explicitly return in Ruby?

前端 未结 8 2210
暗喜
暗喜 2020-11-27 10:59

Coming from a Python background, where there is always a \"right way to do it\" (a \"Pythonic\" way) when it comes to style, I\'m wondering if the same exists for Ruby. I\'v

8条回答
  •  孤街浪徒
    2020-11-27 11:35

    No. Good Ruby style would generally only use an explicit returns for an early return. Ruby is big on code minimalism/implicit magic.

    That said, if an explicit return would make things clearer, or easier to read, it won't harm anything.

提交回复
热议问题