Sometimes you may not know the value of your variable immediately. You can only assign your variable’s value at some later point in time during the execution of your application.
Let’s assume that you need to declare a variable called leastFavoriteDonut of type String, but you won’t initialize it just yet.
scala> var String = _; msg: String = null; scala> msg = "NPN Training";
- We’ve use the wildcard operator _ when defining our variable.