Implicit parameters are the parameters that are passed to a function with implicit keyword in Scala, which means the values will be taken from the context in which they are called. In simpler terms, if no value or parameter is passed to a method or function, then the compiler will look for implicit value and pass it further as the parameter. For example, changing an integer variable to a string variable can be done by a Scala compiler rather than calling it explicitly. When implicit keyword used in the parameter scope of the function, all the parameters are marked as implicit.
Note: A method can only contain one implicit keyword.
def func1(implicit x : Int) // x is implicit
def func2(implicit x : Int, y : Int) // x and y both are implicit
def func3 (x : Int)(implicit y : Int) // only y is implicit
With Implicit parameters: hello world! Without Implicit parameters: hello GFG!
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.