다가오는 3.9.0 릴리스에 into가 확정돼서, 제 코드 중 어디에 활용할 수 있을지 찾아보고 있어요.
궁금한 건 이거예요. 너무 많이 쓸 수도 있나요?
예를 들어 제가 만든 이런 확장을 보면요:
extension [Element](items: IterableOnce[Element])
...
이걸 다음처럼 넓히면 단점이 있을까요:
extension [Element](items: into[IterableOnce[Element]])
...
?
제 확장은 어차피 IterableOnce로 바꾸는 given 변환이 있으면 동작해요. into를 쓰면 경고가 안 뜬다는 차이뿐이고요. 그게 바람직하지 않은 걸까요? 간단히 말해, 유연성을 더 얻으려고 코드 곳곳에 into를 넣으면 안 되는 이유가 뭔가요?
영어에서 번역·원문 보기With into now settled for the forthcoming 3.9.0 release, I'm trying to identify parts of my code that could take advantage of it.
What I'm wondering is: Can it be used too much?
As an example, consider these extensions of mine:
extension [Element](items: IterableOnce[Element])
...
Would there be a downside to broadening that to:
extension [Element](items: into[IterableOnce[Element]])
...
?
My extensions would work regardless with given conversions into IterableOnce. With into, the difference is simply that no warning appears. Is that undesirable? In short, why shouldn't I scatter into throughout my code to gain more flexibilty?