Is there any convention how to name the parameter ...
# codingconventions
k
Is there any convention how to name the parameter to inline classes? Given
inline class User(val user: String)
, I then have to repeat a lot:
val user = User("foo"); println(user.user)
Maybe always give shorter name to the parameter? Maybe
it
?
e
We don’t have anything better than
value
for now. This naming challenge is a sign of a larger problem, though. It looks like the inline value class is a too powerful mechanism for your needs. We are looking to provide simpler and more straightforward alternative in the future to alleviate the issue altogether, see https://youtrack.jetbrains.com/issue/KT-51417
👍 1
k
thanks for taking the time to reply, I think 99% of my usecases do fall into this "restricted types" category. about 80% of the times I use inline types for extra type safety (passing to functions, puttin into classes) but want the inline class to behave exactly as the underlying type all of the time... this extra syntactic indirection doesn't buy me anything. about 20% of the times I use inlines to do some validation on the value and later be sure it hasn't changed watching the issue definitely!
2