You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala.util.Random wraps a java.util.Random. So, it delegates to any class that extends java.util.Random. An implicit conversion can unwrap it with negligible cost. Commons Math3 has a RandomAdapter that extends java.util.Random. Thus, it conforms with scala.util.Random. An additional implicit conversion to a RandomGenerator lets a RandomAdapter-wrapping scala.util.Random work with Commons Math3.
This feels like a damn ugly solution, but it has its pluses. For one, it is unobtrusive to Scala developers. They expect scala.util.Random. And, it works seemlessly with libraries that expect a java.util.Random. Finally, it provide a general pattern for interoperability with libraries that roll their own RNG hierarchies.
What is the proper default? Are implicit wrapping conversions too expensive?
The text was updated successfully, but these errors were encountered: