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 inflection_point = 1 else inflection_point = 0 end
Using the method booleanObjectMethodToInt, we can convert a boolean value to an integer the same way we did with the static method.
If the Boolean value is true , the result is an int with a value of 1. If the scalar value is equal to 0, the Boolean value is 0; otherwise the Boolean value is 1.
Python convert boolean to integer To convert boolean to integer in python, we will use int(bool) and then it will be converted to integer.
To convert Boolean to String in Java, use the toString() method. For this, firstly, we have declared two booleans. String str1 = new Boolean(bool1). toString(); String str2 = new Boolean(bool2).
inflection_point = (firm.inflection_point ? 1 : 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With