Created
July 6, 2018 13:59
-
-
Save jimkang/ac798bcc18f469ae027e1d19d55bd5af to your computer and use it in GitHub Desktop.
Fairly similar lines of code seem to compile differently here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(s: String, mode: NameMode): String = | |
if (s.matches("\\d+")) { | |
return render(SafeLong(s.toInt), mode); | |
// The line below seems to compile. | |
} else if (s.charAt(0) == '-') { | |
"negative " + render(s.substring(1).toInt, mode) | |
} else if (s.length < 2) { | |
val c = s.charAt(0) | |
if (charIsAlpha(c)) { | |
onesForChar(c) | |
} else { | |
mode.ones(c.toInt) | |
} | |
} else if (s.length < 3) { | |
val firstChar:Char = s.charAt(0) | |
val secondChar = s.charAt(1) | |
// This line does not compile. `[error] /Users/jimkang/gcw/zillion/src/main/scala/zillion/Util.scala:82:7: type mismatch; | |
// [error] found : Unit | |
// [error] required: String | |
// [error] if (firstChar == '1') { | |
// [error] ^ | |
if (firstChar == '1') { | |
if (charIsAlpha(s.charAt(1))) { | |
teensForChar(s.charAt(1)) | |
} else { | |
mode.teens(s.toInt - 10) | |
} | |
} | |
... | |
} else { | |
throw new IllegalArgumentException(s"number is >= 10^3003") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this was actually a scope issue. This worked.