changeset 36 | f5ed0fef41b3 |
parent 13 | 0ce25f816414 |
child 37 | 38f3868891f0 |
34:40424bbe109e | 36:f5ed0fef41b3 |
---|---|
1 // sudoku |
1 // sudoku |
2 // some none |
2 // some none |
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 |