What is the difference between apply and also. From what I know the following code does the same thing:
apply
val person = Person().apply {
name = "Tony Stark"
age = 52
// More such stuff
}
also
val person = Person().also {
it.name = "Tony Stark"
it.age = 52
// More such stuff
}
有什么区别吗?我应该使用其中一个吗?还有,在某些情况下,一个有效,另一个无效吗?