I was reading the description of the Scala WartRemover tool, and was confused by one of the points they had. The description said this:
return
breaks referential transparency. Refactor to terminate computations in a safe way.// Won't compile: return is disabled def foo(n:Int): Int = return n + 1 def foo(ns: List[Int]): Any = ns.map(n => return n + 1)
This doesn't make any sense to me, and both of the examples look referentially transparent. Is there some way in which the return
keyword makes it any more likely for a function to break referential transparency? Am I just completely misunderstanding their point?