I'm a beginner learning Scala. I was referring to the Scala documentation.
The documentation says:
The REPL isn’t 100% the same as working with source code in an IDE, so there are a few things you can do in the REPL that you can’t do when working on real-world code in a project. One example of this is that you can redefine a
val
field in the REPL, like this:
scala> val age = 18
age: Int = 18
scala> val age = 19
age: Int = 19
val
fields can’t be redefined like that in the real world, but they can be redefined in the REPL playground.
They have mentioned that it works differently, but what is the need for that?
Also, I have noticed that Scala is weakly-typed when I use it as Worksheet on Scastie but, strongly-typed when I turn off the worksheet mode. Why does a language behave differently in two different modes?
Edit: There was confusion. Scala works the same in no-worksheet mode.