티스토리 뷰

 

 

This is what's called a "variadic parameter." It means that the function can take more than one value of that type. The function's block will have access to an array-like structure (I can't remember if it's an actual array or not), which can be iterated on and used to perform some work on all of the members in it.

So in the example you posted, that function can take a variable number of Ints, passed into the numbers parameter. Inside the function, we iterate through numbers and add them all up, and then return the result.

EDIT: It turns out that the parameter is actually an array of the type declared in the parameter list. Also, worth noting is that you can only have one variadic parameter per function, and it has to be the last parameter in the list.

 

 

 

하나 이상의 값이 들어올 수 있다는 것!

 

정말 신기하다...

심지어 배열 형태도 아님. 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
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
글 보관함