Anonymous user
User input/Text: Difference between revisions
m
→{{header|Ruby}}: Added floating point example, with alternative conversion
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
m (→{{header|Ruby}}: Added floating point example, with alternative conversion) |
||
Line 1,419:
<lang ruby>print "Enter a string: "
s = gets
i = gets.to_i # If string entered, will return zero
printf "Enter a real number: "
f = Float(gets) rescue nil # converts a floating point number or returns nil
puts "String = #{s}"
puts "Integer = #{i}"
puts "Float = #{f}"</lang>
=={{header|Rust}}==
This program shows all the proper error handling.
|