Menu
  • HOME
  • TAGS

Why it's impossible to override `var` with `def` in Scala?

scala,immutability,lsp,mutability,uap

That's related to the Liskov Substitution Principle: you can't assign weaker access privileges in subclass (even for Java). Making var a def makes the setter def x_= (y: T ): Unit private (as @Staix said). So in case when Seadan Car has formal type Car it should not be accessed,...

Universal Windows Platform and SignalR (Could not load file or assembly 'System.Net, Version=2.0.5.0)

c#,signalr,win-universal-app,visual-studio-2015,uap

it's a bit crude, but I have found a fix/workaround. Basically you have to make sure you use the assembly from the WinRT project in stead of the two that NuGet attaches. See http://dotnetbyexample.blogspot.nl/2015/05/getting-signalr-clients-to-work-on.html for details

What does “fields and methods are equivalent” mean?

scala,methods,field,uap

Well it simply means that you can define an abstract val by a def and an abstract def by a val. For example trait Server { def port:Int } has an abstract function, namely port. You can for sure implement (or define or override) this with a def, like this...