Skip to content

Instantly share code, notes, and snippets.

@jminchew97
Created November 3, 2015 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jminchew97/38b94ee200b3ded1223e to your computer and use it in GitHub Desktop.
Save jminchew97/38b94ee200b3ded1223e to your computer and use it in GitHub Desktop.
Simple log in app
puts "Enter a Username"
user = gets.chomp
i = 0
while user.length < 5
puts "Username must be atleast 5 characters long."
user = gets.chomp
end
puts "please enter a password"
pass = gets.chomp
while pass.length < 5
puts "Password must be atleast 5 characters long."
pass = gets.chomp
end
print "Sign up complete."
puts "Please log in!"
puts "Enter Username."
uname = gets.to_s
while uname != user
puts "Try your username again."
uname = gets.to_s
i + 1
unless i == 5
puts "nope."
end
end
puts "enter your password."
pword = gets.to_s
@hxegon
Copy link

hxegon commented Nov 3, 2015

line 24: while loop isn't necessary. or the incrementor.

  while gets.to_s != user
    # i + 1 doesn't change i. i += 1 would increment by 1
    puts "Incorrect. Try again."
  end

@hxegon
Copy link

hxegon commented Nov 3, 2015

line 3, 28-30 don't do anything.

i + 1 # doesn't do anything.
i += 1 # changes the i variable to be one more than it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment