What are implicit parameters?

Implicit parameters are extra help that a function gets without being asked, kind of like a sneaky friend who shows up to help you finish your homework.

Imagine you're playing with building blocks, and you have a robot friend named Bob. When you tell Bob to stack blocks, he automatically knows how high to stack them, even though you didn’t say anything about the height. That’s because Bob has hidden instructions, he was given extra help that lets him do his job better.

How it works

Think of a function as someone who does a task for you. Sometimes, they need extra help to get the job done. These helps are called implicit parameters, and they're passed in without you needing to say anything about them.

For example, when you write a letter, you don’t have to tell your pen how hard to press, it just knows. The pen gets its own kind of hidden help to do the job well.

Take the quiz →

Examples

  1. When you call a function like add(2, 3), the numbers 2 and 3 are explicit parameters. But if you use a function like greet() without any values, it might still know who to greet, those hidden values are implicit parameters.
  2. Imagine asking your friend for help with math, but they already know what problem you're working on, the context is an implicit parameter.
  3. In a game, if a character always knows where you are, that position is passed as an implicit parameter.

Ask a question

See also

Discussion

Recent activity