This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list.map { | |
element => | |
something() | |
f(element) | |
somethingElse() | |
} | |
future.map { case Data(d) => | |
f(d) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.kinja.mantle.overlord.model.template.sections.SidebarData | |
import com.kinja.mantle.overlord.assembly._ | |
import com.kinja.mantle.overlord.controller.TemplateRendering | |
import com.kinja.mantle.overlord.model.{ KinjaRequest, KinjaResponse } | |
import com.kinja.mantle.overlord.model.NewRelicConfig | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import com.kinja.mantle.model.DetectedFeature | |
import com.kinja.mantle.apiclient.PostApiClient | |
import play.modules.statsd.api.Statsd | |
import com.kinja.common.model.Id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.kinja.common.model.Id | |
import com.kinja.mantle.model.DetectedFeature | |
import com.kinja.mantle.overlord.model.template.sections.SidebarData | |
import com.kinja.mantle.overlord.model.KinjaRequest | |
import com.kinja.mantle.overlord.model.KinjaResponse | |
import com.kinja.mantle.overlord.model.NewRelicConfig | |
import com.kinja.mantle.overlord.assembly._ | |
import com.kinja.mantle.overlord.assembly.sections._ | |
import com.kinja.mantle.overlord.assembly.layout.Master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class MyPreciousModel( | |
id: Id, | |
name: Option[String] = None, | |
description: Option[String] = None, | |
meta: Option[MyPreciousMeta] = None | |
) { | |
def setName(value: String) = this.copy(name = Some(value)) | |
def setDescription(value: String) = this.copy(description = Some(value)) | |
def setMeta(value: MyPreciousMeta) = this.copy(meta = Some(value)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class MyPreciousModelDefined( | |
id: Id, | |
name: String, | |
description: String, | |
meta: MyPreciousMeta | |
) | |
case class MyPreciousModelWithNameWithDescription( | |
id: Id, | |
name: String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object chapter2 { | |
def simplefib(n: Int): Int = | |
if (n <= 1) n | |
else simplefib(n - 1) + simplefib(n - 2) | |
def fib(n: Int): Int = { | |
@annotation.tailrec | |
def loop(i: Int, acc: Int, x: Int): Int = | |
if (i <= 0) acc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function simplefib(n) { | |
if (n <= 1) { | |
return n; | |
} else { | |
return fib(n - 1) + fib(n - 2); | |
} | |
} | |
function fib(n) { | |
var loop = function(i, acc, x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.ActorSystem | |
import akka.actor.Status | |
import akka.pattern.ask | |
import akka.pattern.AskTimeoutException | |
import akka.util.Timeout | |
import akka.util.ByteString | |
import akka.io.IO | |
import akka.http.Http | |
import akka.http.model._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation._ | |
object chapter3 { | |
/** | |
* PATTERN MATCHING | |
*/ | |
val foo = (1, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.libs.json._ | |
/** | |
* IdT represents a typed unique identifier. The type of IdT is the type of the | |
* object that it points to. Thus an IdT[Blog] is the unique identifier of a blog. | |
* It is meant to be imported as import IdT => Id to replace old non-typed ids | |
* which are of type IdT[Nothing]. The covariance of IdT is only for backward | |
* compatibility. | |
*/ | |
class IdT[+A] private (val key: Long) extends AnyVal with Ordered[IdT[_]] with Serializable { |