--- 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