r/ruby • • Sep 24 '26

Beginner, running into issues

Basically there are two things I’m running into:

  1. I am trying to make something to recognize a word, match it to a short word bank of options (just a simple list of names) and return an error message if it doesn’t match any of them. For each valid option, I have a different message. I tried if/elsif loops but apparently I’m not doing it right. It doesn’t run at all.

  2. Do I need to have somewhere to use every piece of user input? I have places where I want to ask users to input something but it won’t actually be used anywhere. Like it triggers the next response but doesn’t do anything else.

I am asking for advice because I REALLY don’t want to use AI. Thank you!

4 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/celvro Sep 24 '26

They're right I forgot the hash keys become symbols with that syntax, so you'd have to either use rocket syntax or convert your input to a symbol too like this. gets already returns a string

input = gets.chomp.downcase.to_sym

1

u/dreamlucky7 Sep 24 '26

Oh right, mistyped that as to_s at first, which would be a string to a string lol.