what is wrong here? ` def claim_free_popcorn! @member == true ? '🍿' : notmovieclubmembererror.new("not a member") end` in ruby

The issue in the code is the incorrect usage of the equality comparison operator (==) and the incorrect initialization of an exception. Also, the code has extra spaces and lacks proper indentation.

Here's the corrected code:

main.rb
def claim_free_popcorn!
  @member == true ? '🍿' : raise NotMovieClubMemberError.new("not a member")
end
105 chars
4 lines

In the corrected code:

  • The equality comparison operator == is used to check if @member is equal to true.
  • If @member is true, it returns the popcorn emoji '🍿'.
  • If @member is not true, it raises a NotMovieClubMemberError exception using the raise keyword and the new method to initialize the exception.

Please note that you need to define the NotMovieClubMemberError class earlier in your code.

related categories

gistlibby LogSnag