1. Conclusion </ b>
2. How to write </ b>
3. What I learned from here </ b>
Prepare multiple variables and prepare multiple with return </ b>!
python
def calculation(num)
no1 = (num + 100) * 100
no2 = (num + 10) * 200
return no1,no2
end
num = gets_to.i
a,b = calculation(num)
By doing the above, multiple variables were prepared (➡︎a, b), and multiple variables were prepared by return (➡︎no1, no2). Then, multiple return values (➡︎no1, no2) can be returned for the input argument (➡︎num). As a caveat, the variable will be "nil" if you do not prepare the number of variables to be substituted for the number of prepared variables (left side).
Referenced URL:
Variable assignment when there are multiple return values
I knew that I could assign multiple variables, but I didn't think there were so many different ways to assign variables. I will post about multiple assignment from the URL below!
Referenced URL:
Ruby multiple assignment summary
Recommended Posts