Inserting a value for a parameter using gets.strip or gets.chomp

edited January 2018 in Ruby Scripting
Hi,

In my Ruby code I intend to give a warning when a value is not given for a parameter. In that case I want the user to accept a default value being assigned to that parameter.

This is usually done by "gets.chomp" or "gets.strip". However, I get an error when I use either of these. Any solution in mind?


def x?
while true
print "Would you like to use the default value? [y/n]: "
case gets.strip
when 'Y', 'y','yes'
x = @xx
puts 'Default value has been assigned'
when /\A[nN]o?\Z/ #n or no
break
end
end
end

Comments

  • edited November -1
    Never mind, I think I found a solution for this one:

    value = RBA::InputDialog.get_int("Trench_width", "Give a value for trench width",default )
Sign In or Register to comment.