Skip to content

Instantly share code, notes, and snippets.

@VintageAppMaker
Last active March 18, 2018 08:14
Show Gist options
  • Save VintageAppMaker/7efa24e5fcf4e2fc0b56afe2eede9327 to your computer and use it in GitHub Desktop.
Save VintageAppMaker/7efa24e5fcf4e2fc0b56afe2eede9327 to your computer and use it in GitHub Desktop.
class 회사평가 {
val m = mapOf<String, Int>(
"일이좋다" to 25,
"자부심" to 30,
"높은연봉" to 25,
"유명회사" to 20,
"야근당연" to -60)
var 만족도 : Int = 0
// infix는 확장함수나 멤버함수로 구현되어야 한다.
infix fun 추가(s : String) : Int{
this.만족도 += m[s]!!
return this.만족도
}
}
fun main(args: Array<String>) {
// 삶은 이런 것!!
var 내회사 = 회사평가()
내회사 추가 "일이좋다"
내회사 추가 "자부심"
내회사 추가 "높은연봉"
내회사 추가 "유명회사"
내회사 추가 "야근당연"
println(내회사.만족도)
}
@VintageAppMaker
Copy link
Author

결과화면
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment