like say I have this ``` var mileageValuesToYears...
# getting-started
o
like say I have this
Copy code
var mileageValuesToYears = mapOf(
    1980 to 900000,
    1981 to 900000,
    1982 to 100000,
    1983 to 120000
)
k
Copy code
object Constants {
  val mileageValuesToYears = ...
}
a
That isn't a lot different than having it "sitting in a constant file as a val" though... I guess it depends on how you use it/where it makes sense to have it But imo it doesn't make sense to put it in some "constants" thing, why not make it a "thing" on its own? Like perhaps just a file with only that val or maybe something like
Copy code
object MileageValueToYears : Map<Int, Int> by mapOf(
  1980 to 900000
  // ...
)
k
That behaves the same as the val but with extra (unintuitive) steps...
o
yea i guess, just for neatness i guess
s
I'm pretty sure idiomatic for Kotlin would be using
val
.
mapOf
gives you a read-only map. So your data is immutable (or at least communicates the wish to be immutable, you could probably cast the map to a MutableMap and change stuff)