How do I convert boolean values to integers?

后端 未结 7 1070
日久生厌
日久生厌 2020-12-16 10:39

I have a boolean value to check if it is true, then set a local variable. How do I refactor this so it is more Ruby-ish?

if firm.inflection_point
  inflectio         


        
7条回答
  •  独厮守ぢ
    2020-12-16 10:58

    Here's another method:

    5 - bool.to_s.length

    This takes advantage of the fact that 'true' has four characters, while 'false' has 5.

提交回复
热议问题