Bird
0
0

Which of the following is a valid requirement for a Kotlin function to be declared as infix?

easy📝 Conceptual Q2 of 15
Kotlin - Functions
Which of the following is a valid requirement for a Kotlin function to be declared as infix?
AIt must be a private function inside a class
BIt must return Unit and have no parameters
CIt must be a member function or an extension function with a single parameter
DIt must be a top-level function with multiple parameters
Step-by-Step Solution
Solution:
  1. Step 1: Recall infix function requirements

    An infix function must be a member or extension function with exactly one parameter.
  2. Step 2: Match options with this rule

    Only It must be a member function or an extension function with a single parameter matches this rule; others violate parameter count or visibility rules.
  3. Final Answer:

    It must be a member function or an extension function with a single parameter -> Option C
  4. Quick Check:

    Infix function requirements = Single parameter member/extension function [OK]
Quick Trick: Infix functions need exactly one parameter and be member or extension [OK]
Common Mistakes:
MISTAKES
  • Allowing multiple parameters
  • Thinking top-level functions can be infix
  • Assuming private visibility is required

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes