코틀린에서 에러:Cannot perform refactoring without an expression 에러
조회수 631회
방학중에 코틀린을 공부하려는 대학생입니다 책으로 예제 작성중 "Cannot perform refactoring without an expression이라는 에러가 발생하는데 책의 예제와 같은 코드인데 왜 발생하는지 잘 모르겟어서 질문드립니다 IDEA는 인텔리제이입니다
val name="마드리갈"
var healthPoints=95
val isBlessed=true
val isImmortal=false
val race="gnome"
val faction = when (race){
"dwarf"->"Keepers of the mines"
"gnome"->"Keepers of the Mines"
"orc"->"free People of Rolling Hills"
"human"->"Free PeoPle of the Rolling Hills"
else->null
}
//아우라
//if(isBlessed&&healthPoints>50||isImmortal){
val auraVisible=isBlessed&&healthPoints>50||isImmortal
/* if(auraVisible){
println("Green")
}else {
println("None")
}*/
/* if (healthPoints==100) {
// val healthStatus=if(healthPoints==100){
println(name + "최상의 상태임")
// }else if(healthPoints>=90){
}else if (healthPoints in 90..99) {
if (isBlessed) {
println(name + "약간의상처가있지만 빨리 치유됨")
} else {
println(name + "약간의 찰과상만 입음")
}
//}else if(healthPoints>=80){
} else if(healthPoints in 80..89){
println(name+"경미한 상처")
}else if(healthPoints>=70){
println(name+ "많이 다친것 같음")
}
else
println(name+"최악의 상태임")
}*/
val healthStatus = when (healthPoints){
100->"최상의 상태임"
in 90..99-> "약간의 찰과상"
in 75..89-> if (isBlessed){
"경미한 상처는 있지만 빨리 치유되고 있음"
}else{
"경미한 상처만 있음"
}
in 15..74->"많이 다침"
else-> "최악의 상태임"
}//플레이어의 상태 출력
//println(name +" "+ healthStatus)
val auraColor= if (auraVisible)"GREEN" else "NONE"
//플레이어의 상태 출력
println("(Aura: $auraColor)"+"(Blessed: ${if (isBlessed)"YES" else "NO"})")
println("$name $healthStatus")
가 코드 전문이고 val healthStatus 하위 라인을 함수로 만드려는 예제입니다
댓글 입력