How can I make just the first letter of user input capitalized, so that if they enter the same movie title as one given, but all in lowercase, they can still receive the error message that the title already exists?



movies = {
    Movie: 1,
    Moviee: 2,
    Movieee: 3,
    Movieeee: 4}
    puts "What we gonna do?" 
    case choice
    when "add"
    puts "Added!"
    when "update"
    puts "title?"
    title=gets.chomp(/./, &:upcase)
    if movies[title.to_sym]
        puts "rating"
    rating = gets.chomp.sub
        puts "Title has been updated!"
        puts "That Doesn't Exist!"
    when "display"
    puts "movies!"
    when "delete"
    puts "delete"


I have it set up this way, why is this not working? I


See if there aren't any string methods for that, you can call the method methods to find out what is available or you can look it up in documentation or google for it.

irb(main):001:0> puts 'hello'.methods.sort


Just do title = gets.chomp.capitalize or whatever = blah.blah.capitalize to capitalize something.


WOW. Rookie mistake sorry! Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.