I have a function where I get input from a user
def get_single_argument(argument,name)
begin
puts "Type #{name}: "
argument = STDIN.gets.chomp
puts "#{name} --> #{argument} OK??"
happy = STDIN.gets.downcase.chomp
end until (happy.strip[0,1].to_s =='y' )
end
but when I call this function where the argument is a global variable the global variable is not updated. How can I assign a value to a global variable which name is passed as a function argument? $web_url is ” – empty string.
$web_url =''
puts "url je:#{$web_url}"
get_single_argument($web_url,"web url")
puts "url je:#{$web_url}"
You can use
String.replaceinside your method. Instead ofyou can write