0

What is the purpose of the porcent symbol(%); modulus operator in the ruby programming?

x=5 y=2 puts x%2 #outputs 1

4th May 2017, 1:33 AM
Luis Oscar Salazar Gómez
Luis Oscar Salazar Gómez - avatar
2 Antworten
+ 2
One example is to convert total seconds to "hour:minute" format. To get the "second" part you need totalSecond%60
4th May 2017, 2:15 AM
Calviղ
Calviղ - avatar
0
the purpose is remainder value store by the division.
4th May 2017, 1:40 AM
Luis Oscar Salazar Gómez
Luis Oscar Salazar Gómez - avatar