02-28-2021, 08:28 AM
Example 1.
Let's see if 1 is even by executing the following code:
This will print "false" on the screen, because 1 is not even.
Example 2.
Let's see if 2 isĀ even by executing the following code:
This will print "true" on the screen, because 2 is even.
Example 3.
Let's see if 1 is odd by executing the following code:
This will print "true" on the screen, because 1 is odd.
Example 4.
Let's see if 2 is odd by executing the following code:
This will print "false" on the screen, because 2 is not odd.
Let's see if 1 is even by executing the following code:
Quote:puts 1.even?
This will print "false" on the screen, because 1 is not even.
Example 2.
Let's see if 2 isĀ even by executing the following code:
Quote:puts 2.even?
This will print "true" on the screen, because 2 is even.
Example 3.
Let's see if 1 is odd by executing the following code:
Quote:puts 1.odd?
This will print "true" on the screen, because 1 is odd.
Example 4.
Let's see if 2 is odd by executing the following code:
Quote:puts 2.odd?
This will print "false" on the screen, because 2 is not odd.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos