map.getOrDefault(key, defaultValue) 함수 호출을 색인 생성 및 elvis 연산자(map[key] ?: defaultValue)로 바꿉니다.

예:


  fun test(map: Map<Int, String>) {
      map.getOrDefault(1, "foo")
  }

  fun test(map: Map<Int, String>) {
      map[1] ?: "foo"
  }