Currently playing a bit more with the `when` expre...
# codereview
d
Currently playing a bit more with the
when
expression readability wise (more specific if it improves the readability in one line functions with branching)
Copy code
fun calculatePartWidth(part: Draft) = when(part) { sign -> maxWidth else -> defaultWidth }

fun calculatePartWidth(part: Draft) = if(part == sign) maxWidth else defaultWidth
Which of those would you prefer? My personal opinion is that the when saves one from doing a refactoring there, which would be along the lines of:
if(isASign(part)) maxWidth else defaultWidth