Ruby - MethodsWhich statement about Ruby method definitions using def is TRUE?AMethods must always have parentheses around parametersBMethods can return the last evaluated expression without an explicit returnCMethods cannot have optional parametersDMethod names can include spaces if enclosed in quotesCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall Ruby method syntax rulesParentheses around parameters are optional, so A is false.Step 2: Understand return behaviorRuby methods return the last evaluated expression automatically, so C is true.Step 3: Check optional parameters and namingRuby supports optional parameters, so B is false. Method names cannot have spaces, so D is false.Final Answer:Methods can return the last evaluated expression without an explicit return -> Option BQuick Check:Implicit return is Ruby method feature [OK]Quick Trick: Ruby methods return last expression automatically [OK]Common Mistakes:Thinking parentheses are mandatoryBelieving explicit return is requiredAssuming method names can have spaces
Master "Methods" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Arrays - Array slicing and ranges - Quiz 6medium Hashes - Hash methods (keys, values, each) - Quiz 6medium Loops and Iteration - Until loop - Quiz 2easy Methods - Predicate methods (ending with ?) - Quiz 3easy Methods - Explicit return statement - Quiz 15hard Methods - Explicit return statement - Quiz 14medium Operators and Expressions - Logical operators (&&, ||, !) - Quiz 10hard Ruby Basics and Runtime - IRB for interactive exploration - Quiz 14medium String Operations - Why strings are mutable in Ruby - Quiz 4medium Variables and Data Types - Dynamic typing vs strong typing - Quiz 6medium