Kotlin
[Kotlin Tips] Deduplicating Collection Items
https://www.youtube.com/watch?v=ECOf0PeSANw 코틀린의 콜렉션 (리스트, Set,,) 에서 중복을 제거하는 방법에 대해서 꿀팁을 알려준다고 한다! val fruitBasket = listOf( "Apple", "Banana", "Cherry", "Apple", "Apple", "APPLE", "BANANA", "Durian" ) 자 요런 리스트가 있다고 생각해보자~! 이때 여기서 중복된 과일이 보인다! Apple이 왜이렇게 많은 거야,,?! 여기서 중복된 과일을 지워보자! 이때 어떤 방법이 생각나나요? 일단 두가지 방법이 머릿속에 삭 스칠 것이다. 방법 1. distinct() 함수를 사용한다. fun main() { val unique = fruitBasket.disti..
[Kotlin Tips] Kotlin에서 Shadowing을 다루는 방법
Fully Qualified Names to the Rescue! | Kotlin Tips 5월 20일에 올라온 따끈따끈한(?) 영상이다! 만약에 이런 코드가 있다고 생각해보자. package io.sebi.demo fun openFile() { println("Opening file (top level)...") } class Repo { fun openFile() { println("Opening file (repository)...") } fun readFile() { openFile() } } 이때 readFile()을 호출한다면 출력 값은 어떤게 나올까? 다들 당연히 알겠지만 Opening file (repository)...이다. 근데 Kotlin에서는 shadowing일 경우에 탑 레벨에 있..