Confusion about brackets vs. parenthesis


#1



If you look down at the code, when I try to delete one of my entries that I already have in my code at the start, it tells me "wrong number of arguments (1 for 0). But when I replace the brackets in else
movies.delete(title.to_sym)
puts "Title has been removed."
end

with parenthesis, it works. Why is this?


when "delete"
    puts "Which entry would you like to delete?"
    title=gets.chomp
    if movies[title.to_sym].nil?
        puts "There is no entry by that name."
    else
        movies.delete[title.to_sym]
        puts "Title has been removed."
    end


#2

Are square brackets used to call methods? You just have to ask yourself what action you're doing and then consider/look up what the corresponding syntax is


#3

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