author | Christian Urban <urbanc@in.tum.de> |
Thu, 10 Nov 2016 16:10:39 +0000 | |
changeset 36 | f5ed0fef41b3 |
parent 13 | 0ce25f816414 |
child 37 | 38f3868891f0 |
permissions | -rw-r--r-- |
8 | 1 |
// sudoku |
13
0ce25f816414
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
2 |
// some none |
36 | 3 |
|
4 |
||
5 |
||
6 |
||
7 |
// Implicits |
|
8 |
//=========== |
|
9 |
// |
|
10 |
// for example adding your own methods to Strings: |
|
11 |
// imagine you want to increment strings, like |
|
12 |
// |
|
13 |
// "HAL".increment |
|
14 |
// |
|
15 |
// you can avoid ugly fudges, like a MyString, by |
|
16 |
// using implicit conversions |
|
17 |
||
18 |
||
19 |
implicit class MyString(s: String) { |
|
20 |
def increment = for (c <- s) yield (c + 1).toChar |
|
21 |
} |
|
22 |
||
23 |
"HAL".increment |