스칼라
// For-comprehensions // Since lifting functions is so common in Scala, Scala provides a syntactic construct // called the for-comprehension that it expands automatically to a series of flatMap and // map calls. Let’s look at how map2 could be implemented with for-comprehensions. // Here’s our original version: def map2[A,B,C](a: Option[A], b: Option[B])(f: (A, B) => C): Option[C] = a.flatMap(aa => b.map(bb => f(aa, bb) ) ) // And here’s the exact same code written as a for-comprehension: def map2[A,B,C](a: Option[A], b: Option[B])(f: (A, B) => C): Option[C] = for { aa <- a bb <- b } yield f(aa, bb) // A for-comprehension consists of a sequence of bindings, like aa <- a, followed by a // yield after the closing brace, where the yield may make use of any of the values // on the left side of any previous <- binding. The compiler desugars the bindings to // flatMap calls, with the final binding and yield being converted to a call to map. // You should feel free to use for-comprehensions in place of explicit calls to flatMap // and map.코틀린은 위에 표현밖에 지원 안 함
스칼라는 밑에 것도 지원하고
글고 스칼라는 기본 들여쓰기 2칸인데 코틀린은 4칸이라 위에 방법대로 쓰면 더 더러워보임
봐도 뭐하는 함수인지 모르겠다
스칼라 신텍스는 언제봐도 좆 같아서 도저히 이해를 못하겠다 - return 0;
스칼라 저거 좆같을거 없는게 걍 하스켈 do표현법임
이래서 제가 설탕 뿌리는걸 싫어함 직관성이 존나 떨어져 - return 0;