MG
Size: a a a
MG
AM
MG
AM
Collection<T>.toMutableList(): MutableList<T>
, for example, always makes a copy, so bothsetOf(1, 2, 3).toMutableList()[0] = 5
mutableListOf(1, 2, 3).toMutableList()[0] = 5
fun VectorCore.toVectorBase() =
if(this is VectorBase)
this
else
VectorBase().also { it.addAll(this) }
AM
AM
VectorBase
, you'll get the same object. If you call it on other VectorCore
, you'll get a copy.AM
toVectorBase
but asVectorBase
— this is a convention most of standard library follows.VT
AM
toSmth
developers wouldn't expect that changes to resulting object propagate to source, with asSmth
it could and it's expected.AM
VT
AM
MG
AM
VT
AM
android {
flavorDimensions "server"
productFlavors {
dev {
dimension "server"
buildConfigField "String", "BACKEND_URL", "\"http://dev.example.org\""
}
prod {
dimension "server"
buildConfigField "String", "BACKEND_URL", "\"http://example.org\""
}
}
}
assembleDebug
будут assembleDevDebug
и assembleProdDebug
, а в классе BuildConfig
появится поле BACKEND_URL
.MG
toSmth
developers wouldn't expect that changes to resulting object propagate to source, with asSmth
it could and it's expected.clone()
itself returns a new copy as VectorCore()
, and if the type is VectorBase()
then operations involved on it should probogate to its VectorCore() instanceval v1 = VectorCore()i would expect v2 to be v1 cast to VectorBase such that modifying v2 also modifies v1
val v2 = v1 as VectorBase
val v2 = v1.toVectorBase()
would create a copy of VectorCore cast to VectorBase such that modifying v2 will not modify v1AM
AM
clone()
itself returns a new copy as VectorCore()
, and if the type is VectorBase()
then operations involved on it should probogate to its VectorCore() instanceval v1 = VectorCore()i would expect v2 to be v1 cast to VectorBase such that modifying v2 also modifies v1
val v2 = v1 as VectorBase
val v2 = v1.toVectorBase()
would create a copy of VectorCore cast to VectorBase such that modifying v2 will not modify v1