mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Use the right comment style for Scala... oops
This commit is contained in:
parent
9870ca23eb
commit
29bc9a1449
@ -28,9 +28,9 @@ Scala - the scalable language
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 1. Basics
|
// 1. Basics
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
// Single line comments start with two forward slashes
|
// Single line comments start with two forward slashes
|
||||||
|
|
||||||
@ -138,9 +138,9 @@ val html = """<form id="daform">
|
|||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 2. Functions
|
// 2. Functions
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
// The next line gives you a function that takes an Int and returns it squared
|
// The next line gives you a function that takes an Int and returns it squared
|
||||||
(x:Int) => x * x
|
(x:Int) => x * x
|
||||||
@ -165,9 +165,9 @@ sq(10) // Gives you this: res33: Int = 100.
|
|||||||
val add10: Int => Int = _ + 10
|
val add10: Int => Int = _ + 10
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 3. Flow Control
|
// 3. Flow Control
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
1 to 5
|
1 to 5
|
||||||
val r = 1 to 5
|
val r = 1 to 5
|
||||||
@ -220,9 +220,9 @@ println(if (x == 10) "yeah" else "nope")
|
|||||||
val text = if (x == 10) "yeah" else "nope"
|
val text = if (x == 10) "yeah" else "nope"
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 4. Data Structures
|
// 4. Data Structures
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
val a = Array(1, 2, 3, 5, 8, 13)
|
val a = Array(1, 2, 3, 5, 8, 13)
|
||||||
a(0)
|
a(0)
|
||||||
@ -271,9 +271,9 @@ d._1
|
|||||||
d._2
|
d._2
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 5. Object Oriented Programming
|
// 5. Object Oriented Programming
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Aside: Everything we've done so far in this tutorial has been simple
|
Aside: Everything we've done so far in this tutorial has been simple
|
||||||
@ -317,9 +317,9 @@ Person("George", "1234") == Person("Kate", "1236")
|
|||||||
// Objects and traits coming soon!
|
// Objects and traits coming soon!
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 6. Pattern Matching
|
// 6. Pattern Matching
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
val me = Person("George", "1234")
|
val me = Person("George", "1234")
|
||||||
|
|
||||||
@ -358,9 +358,9 @@ matcher("52917") // => "No match on '52917'"
|
|||||||
matcher("52752-16432-22178-47917") // => "Serial key: 52752, 16432, 22178, 47917"
|
matcher("52752-16432-22178-47917") // => "Serial key: 52752, 16432, 22178, 47917"
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 7. Functional Programming
|
// 7. Functional Programming
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
// Scala allows methods and functions to return, or take as parameters, other
|
// Scala allows methods and functions to return, or take as parameters, other
|
||||||
// functions or methods.
|
// functions or methods.
|
||||||
@ -419,16 +419,16 @@ for { n <- s; nSquared = n * n if nSquared < 10} yield nSquared
|
|||||||
a for-comprehension defines a relationship between two sets of data. */
|
a for-comprehension defines a relationship between two sets of data. */
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 8. Implicits
|
// 8. Implicits
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
Coming soon!
|
Coming soon!
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
## 9. Misc
|
// 9. Misc
|
||||||
#################################################
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
// Importing things
|
// Importing things
|
||||||
import scala.collection.immutable.List
|
import scala.collection.immutable.List
|
||||||
|
Loading…
Reference in New Issue
Block a user