How to Get Input with Gets in Ruby

Ruby provides a number of ways to get input from the user. we will use gets in this example. The gets method is basically the opposite of puts — instead of printing stuff, it gathers what the user types for you.


After print statement, collect the user’s input into a variable (shape_size):

puts "Welcome to Shapes"
print "How big do you want your shape? "
print "How big do you want your shape? "
shape_size = gets

 


Flutter Questions

Android Questions

Python Questions

Java Questions