Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't scala.util.Success.apply infinitely recursive?

scala.util.Success doesn't have an apply method but inherits the one from scala.util.Try (AFAIK). But all scala.util.Try.apply does is call Success.apply surrounded by a try catch block. How is this not infinitely recursive and how does this ever trigger the catch block?

like image 645
Shane Kinsella Avatar asked Dec 07 '25 02:12

Shane Kinsella


1 Answers

No, scala's Success is a case class that inherits abstract class Try. So the apply method is a built-in method generated by scala compiler, not inherited from the object Try.

Source https://github.com/scala/scala/blob/2.11.x/src/library/scala/util/Try.scala#L225

like image 111
Herrington Darkholme Avatar answered Dec 08 '25 15:12

Herrington Darkholme



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!