dimanche 1 mars 2015

In Scala, how to use `Nothing` as returned value to Fake a method?

I'd like to create a method called save and haven't been ready to implement it. However, I don't want it to throw exceptions during evaluated. So I tried to make it return a Nothing as the result.



def save[A <: AuthInfo](profile: CommonSocialProfile): Future[UserProfile] = {
// To be done
new Nothing()
}


But this won't work, the compiler says:



class Nothing is abstract; cannot be instantiated



I also tried ??? as a placeholder, but that will throw a NotImplementedError, which doesn't fit my needs either..



def save[A <: AuthInfo](profile: CommonSocialProfile): Future[UserProfile] = ???


Does anyone have easier ways about fake a method in Scala?


Aucun commentaire:

Enregistrer un commentaire