Ruby - MethodsWhat is the main purpose of a predicate method in Ruby?ATo modify global variablesBTo return a boolean value indicating a conditionCTo print output to the consoleDTo perform arithmetic calculationsCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand predicate method namingPredicate methods in Ruby always end with a question mark and are designed to answer yes/no questions.Step 2: Identify the return typeThey return true or false, which are boolean values indicating if a condition is met.Final Answer:To return a boolean value indicating a condition -> Option BQuick Check:Predicate method purpose = boolean return [OK]Quick Trick: Predicate methods always return true or false [OK]Common Mistakes:Thinking predicate methods perform actionsAssuming they return stringsConfusing with methods that print output
Master "Methods" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Arrays - Array creation methods - Quiz 6medium Control Flow - If, elsif, else statements - Quiz 11easy Hashes - Accessing and setting values - Quiz 11easy Loops and Iteration - Loop method for infinite loops - Quiz 2easy Methods - Bang methods (ending with !) - Quiz 5medium Methods - Why methods always return a value in Ruby - Quiz 3easy Ruby Basics and Runtime - What is Ruby - Quiz 12easy Ruby Basics and Runtime - Comments and documentation - Quiz 2easy String Operations - String methods (upcase, downcase, strip) - Quiz 8hard Variables and Data Types - String interpolation with #{} - Quiz 9hard