Permalink
Browse files

Add line breaks in code samples

  • Loading branch information...
Nilhcem committed Jun 8, 2016
1 parent 55e624b commit 58f2fff219400fd92d09c493075734d82b954de8
Showing with 17 additions and 9 deletions.
  1. +2 −1 code/declaration.kt
  2. +2 −1 code/downcasting.kt
  3. +2 −1 code/downcasting.swift
  4. +1 −1 code/function-type.kt
  5. +6 −3 code/subclass.kt
  6. +2 −1 code/subclass.swift
  7. +2 −1 code/tuple-return.kt
View
@@ -1,4 +1,5 @@
class Shape {
var numberOfSides = 0
fun simpleDescription() = "A shape with $numberOfSides sides."
fun simpleDescription() =
"A shape with $numberOfSides sides."
}
View
@@ -1,5 +1,6 @@
for (current in someObjects) {
if (current is Movie) {
println("Movie: '${current.name}', dir. ${current.director}")
println("Movie: '${current.name}', " +
"dir. ${current.director}")
}
}
View
@@ -1,5 +1,6 @@
for current in someObjects {
if let movie = current as? Movie {
print("Movie: '\(movie.name)', dir. \(movie.director)")
print("Movie: '\(movie.name)', " +
"dir. \(movie.director)")
}
}
View
@@ -7,5 +7,5 @@ fun makeIncrementer(): (Int) -> Int {
val increment = makeIncrementer()
increment(7)
// makeIncrementer() can also be written in a shorter way:
// makeIncrementer can also be written in a shorter way:
fun makeIncrementer() = fun(number: Int) = 1 + number
View
@@ -1,17 +1,20 @@
open class NamedShape(val name: String) {
var numberOfSides = 0
open fun simpleDescription() = "A shape with $numberOfSides sides."
open fun simpleDescription() =
"A shape with $numberOfSides sides."
}
class Square(var sideLength: BigDecimal, name: String) : NamedShape(name) {
class Square(var sideLength: BigDecimal, name: String) :
NamedShape(name) {
init {
numberOfSides = 4
}
fun area() = sideLength.pow(2)
override fun simpleDescription() = "A square with sides of length $sideLength."
override fun simpleDescription() =
"A square with sides of length $sideLength."
}
val test = Square(BigDecimal("5.2"), "square")
View
@@ -25,7 +25,8 @@ class Square: NamedShape {
}
override func simpleDescription() -> String {
return "A square with sides of length \(sideLength)."
return "A square with sides of length " +
sideLength + "."
}
}
View
@@ -1,2 +1,3 @@
data class GasPrices(val a: Double, val b: Double, val c: Double)
data class GasPrices(val a: Double, val b: Double,
val c: Double)
fun getGasPrices() = GasPrices(3.59, 3.69, 3.79)

0 comments on commit 58f2fff

Please sign in to comment.