Anonymous user
Integer comparison: Difference between revisions
→{{header|Ruby}}: The first example was broken because the argument to Kernel#gets is the line separator, not the prompt.
(Move 'Korn Shell' to 'UNIX Shell' and backport to pdksh.) |
(→{{header|Ruby}}: The first example was broken because the argument to Kernel#gets is the line separator, not the prompt.) |
||
Line 1,500:
=={{header|Ruby}}==
<lang ruby>a = gets( "enter a value for a: ").to_i
b = gets( "enter a value for b: ").to_i
Line 1,507 ⟶ 1,508:
print "a is greater than b" if a > b
print "a is equal to b" if a == b</lang>
Example '''input''' and output:
$ '''ruby compare.rb'''
enter a value for a: '''5'''
enter a value for b: '''10'''
5 is less than 10
$ '''ruby compare.rb'''
enter a value for a: '''cat'''
enter a value for b: '''dog'''
0 is equal to 0
----
{{trans|Python}}
An alternative method, which is similar to the python version mentioned above (at the time of writing this) is:
|