is that shallow copy is possible in kotlin? how co...
# announcements
r
is that shallow copy is possible in kotlin? how come it works with copy()? while using data class?
k
Please don't crosspost like this.
r
sorry, i posted in wrong group before so only asked the question in #general
can you please explain the shallow and deep copy in kotlin? i can manage to get data class it works fine for deep copy... but i'm not sure about the shallow copy
k
Are you sure that data classes do a deep copy? Do you know the difference?
r
data class Company(var TIN:String, var Size:Int){ } var comp = Company(TIN="12345678910",Size = 100) var compCpy = comp.copy(TIN="123"); comp.Size=90 println("Old Company $comp") println("Copy Company $compCpy")
see here it does the deep copy only
oh okay got it
k
When copying something with only immutable values (
String
,
Int
, ...) there's no difference.
r
ok