Skip to content

Conversation

@Mordiumaco
Copy link
Collaborator

1-2 k번쨰 수 문제 풀이.

기존 체이닝 메서드 말고 한번 그냥 구현하는 방식으로 연습을 해보는 것도 필요할 것 같음.

Copy link
Collaborator

@whdgns5059 whdgns5059 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내부 API를 직접 구현해서 문제를 해결 해보는 것에 동의 합니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만들어질 배열의 길이를 알 수 있는데 List를 사용할 필요가 있을까요

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List를 배열로 만들기 위해 stream api를 거치는 것 보다 toArrray() 메서드를 이용하는게 좋을것 같습니다.
내부에서 mapToInt 내에서 아무 로직도 수행하지 않는데 굳이 필요 할까요?
만약 위에서 길이가 정해진 배열을 만들었다면 List를 배열로 다시 만들 필요가 없을 것 입니다.

Copy link
Collaborator

@whdgns5059 whdgns5059 Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클로저의 내부 변수는 외부에서 참조가 가능해지므로 가비지 컬렉션에 의해 사라지지 않아 함수의 실행 이후 지속적으로 참조가 가능합니다. 다만 자원을 점유하게 되는데요.
이 함수에는 내부변수가 없고 실행이후 지속적으로 참조할 필요가 없는데. 클로저로 작성한 이유가 있나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants