Ruby - MethodsWhat is the main purpose of keyword arguments in Ruby methods?ATo force all arguments to be positionalBTo allow passing arguments by name for clarity and flexibilityCTo make methods run fasterDTo prevent any arguments from being optionalCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand keyword argumentsKeyword arguments let you pass values to a method by naming them explicitly, improving code clarity.Step 2: Compare with other optionsOptions A, C, and D are incorrect because keyword arguments do not force positional use, do not affect speed, and allow optional arguments.Final Answer:To allow passing arguments by name for clarity and flexibility -> Option BQuick Check:Keyword arguments purpose = clarity and flexibility [OK]Quick Trick: Keyword arguments improve readability by naming inputs [OK]Common Mistakes:MISTAKESThinking keyword arguments force positional orderBelieving keyword arguments speed up method callsAssuming keyword arguments make all parameters mandatory
Master "Methods" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Arrays - Array comparison and set operations - Quiz 2easy Arrays - Array comparison and set operations - Quiz 13medium Hashes - Accessing and setting values - Quiz 6medium Hashes - Why hashes are used everywhere in Ruby - Quiz 1easy Hashes - Hash methods (keys, values, each) - Quiz 9hard Loops and Iteration - Times method for counted repetition - Quiz 8hard Loops and Iteration - Loop method for infinite loops - Quiz 11easy String Operations - String methods (upcase, downcase, strip) - Quiz 3easy String Operations - Why strings are mutable in Ruby - Quiz 11easy String Operations - Split and join methods - Quiz 8hard