scala - Pattern matching where failure case return type is Java void -
In my trial, I have code that looks like:
val myVar = getVar () Match {matter something (V) => V case no = & gt; More tests on unsuccessful () // TestNG} // myVar ... // testng public static zero fail () {...} The problem is that myVar < / Code> is assigned the type of any What is the best way to deal with this situation?
first matches its environment (ISH)
Scala & Gt; Def fail (): unit = new runtime exception ("blah") failed to throw: () unit scale & gt; Now write an adapter that is nothing for the unit
> Scala & gt; Def myFail (): nothing = {failed (); ???} myFail: nothing and expected code of use while using the adapter
scala> Val myVar = getVar () match {| In case something (V) = & gt; Wei | No case = & gt; MyFile () | } MyVar: String = Hello By the way, it can be written more clearly
scala> P> / html>
Comments
Post a Comment