티스토리 뷰
scala 초보자들의 한가지 혼란스러운 점은, class는 new keyword 없이 만들어진다는 것이다.(ex: val p = person())
이것은 특별한 함수 apply 덕분이다.
-Apply Function Basics
간단한 apply의 사용 예는 object에 사용한 것이다. 이것은 object가 마치 object 그자체로 함수 인 것 처럼 call 할 수 있다.
출처: https://blog.matthewrathbone.com/2017/03/06/scala-object-apply-functions.html
4 Fun and Useful Things to Know about Scala's apply() functions
Scala's apply functions are commonly seen alongside case classes, but they can do so much more. Here are 4 fun ways they are used in Scala.
blog.matthewrathbone.com
'scala' 카테고리의 다른 글
Make a new project!(Command line를 사용한 프로젝트 생성 방법.) (0) | 2020.09.29 |
---|---|
[scala] - trait, object, class (0) | 2020.03.15 |