Post History
Scala (-language:postfixOps), 4 solutions 1. Just 256: 256 2. Casting a character: +'Ā' The character Ā is 256 in decimal, and the unary + turns it into an Int. 3. Hashcode of a string: ...
Answer
#2: Post edited
- # Scala (`-language:postfixOps`), 4 solutions
```scala- 256
- +'Ā'
""## (two backspace characters inside the string)- (44444&444^444444)&4444
- ```
- [Try them all in Scastie!](https://scastie.scala-lang.org/QAT0gr9cTTeMmYX2tsQn5A)
- I don't have a lot right now, especially because I'm not great at bitwise stuff, but I will hopefully find more later.
- Because of the `""##`, using the flag `-language:postfixOps`, importing `language.postfixOps`, or using Scala 2.12 is required.
- # Scala (`-language:postfixOps`), 4 solutions
- ### 1. Just 256:
- ```
- 256
- ```
- ### 2. Casting a character:
- ```
- +'Ā'
- ```
- The character `Ā` is 256 in decimal, and the unary `+` turns it into an `Int`.
- ### 3. Hashcode of a string:
- ```
- ""##
- ```
- There are two backspace characters in the string (\u0008), so the hashcode is `31*8 + 8 = 256`. `##` is the same as `.hashCode`. Since we're not using `.`, enabling postfix operators is required.
- ### 4. Bitwise stuff:
- ```
- (44444&444^444444)&4444
- ```
- I just messed around for a while until I got this one right. It wastes parentheses and two operators, but I couldn't find anything better.
- [Try them all in Scastie!](https://scastie.scala-lang.org/QAT0gr9cTTeMmYX2tsQn5A)
- I don't have a lot right now, especially because I'm not great at bitwise stuff, but I will hopefully find more later.
- Because of the `""##`, using the flag `-language:postfixOps`, importing `language.postfixOps`, or using Scala 2.12 is required.
#1: Initial revision
# Scala (`-language:postfixOps`), 4 solutions ```scala 256 +'Ā' ""## (two backspace characters inside the string) (44444&444^444444)&4444 ``` [Try them all in Scastie!](https://scastie.scala-lang.org/QAT0gr9cTTeMmYX2tsQn5A) I don't have a lot right now, especially because I'm not great at bitwise stuff, but I will hopefully find more later. Because of the `""##`, using the flag `-language:postfixOps`, importing `language.postfixOps`, or using Scala 2.12 is required.