티스토리 뷰

scala

[scala] - About Scala's apply() functions

signalsunnyA 2020. 3. 15. 20:59

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

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함