diff -r 40424bbe109e -r f5ed0fef41b3 progs/lecture2.scala --- a/progs/lecture2.scala Thu Nov 10 11:41:50 2016 +0000 +++ b/progs/lecture2.scala Thu Nov 10 16:10:39 2016 +0000 @@ -1,2 +1,23 @@ // sudoku // some none + + + + +// Implicits +//=========== +// +// for example adding your own methods to Strings: +// imagine you want to increment strings, like +// +// "HAL".increment +// +// you can avoid ugly fudges, like a MyString, by +// using implicit conversions + + +implicit class MyString(s: String) { + def increment = for (c <- s) yield (c + 1).toChar +} + +"HAL".increment