move demo documents into separate files
This commit is contained in:
parent
8ee1ffab20
commit
426259dc2f
23 changed files with 466 additions and 495 deletions
12
demo/docs/scala.scala
Normal file
12
demo/docs/scala.scala
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//http://www.scala-lang.org/node/227
|
||||
/* Defines a new method 'sort' for array objects */
|
||||
object implicits extends Application {
|
||||
implicit def arrayWrapper[A : ClassManifest](x: Array[A]) =
|
||||
new {
|
||||
def sort(p: (A, A) => Boolean) = {
|
||||
util.Sorting.stableSort(x, p); x
|
||||
}
|
||||
}
|
||||
val x = Array(2, 3, 1, 4)
|
||||
println("x = "+ x.sort((x: Int, y: Int) => x < y))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue