views:

192

answers:

3

I am writing a function which is meant to take a character as an argument and return a character. Using String for this looks a bit strange for me. Should I, or there is something like a char type in Scala 2.8?

+5  A: 

Yes, there is a character type in scala. It's called Char.

Scala also has character literals which are written by surrounding the character with single quotes like in most languages.

sepp2k
+8  A: 
Java    Scala
----    -----
boolean Boolean
byte    Byte
char    Char
int     Int
long    Long
float   Float
double  Double

String  String

I sense a pattern...

Randall Schulz
+1  A: 

If you're only expecting Basic Multilingual Plane characters, use Char. Otherwise, you'll need to use Int. See the JavaDoc for the Character class and this technical article for a discussion of this.

Ben Lings