TIL

아이템 12 연산자 오버로드를 할 때는 의미에 맞게 사용하라

operator fun Int.not() = factorial()

print(10 * !6) // 7200
// 모든 연산자는 함수로도 호출 가능하다. 6.not()
// not이 팩토리얼 계산 함수라는 것은 혼란스럽다.

분명하지 않은 경우

operator fun Int.times(operation: () -> Unit): () -> Unit = 
	{ repeat(this) { operation } }
	
val tripleHello = 3 * { print("Hello") }
tripleHello() // HelloHelloHello
repeat(3) { print("Hello") }

규칙을 무시해도 되는 경우

body {
	div {
		+"Some text" // String.unaryPlus
	}
}