Scala does not have checked exceptions like Java, so you can't do soemthing like this to force a programmer to deal with an exception:
public void stringToInt(String str) throws NumberFormatException {
Integer.parseInt(str)
}
import scala.language.experimental.macros | |
import scala.reflect.macros.blackbox.Context | |
object PrintForMacros { | |
def printFor[A](expr: A): A = | |
macro PrintForMacros.printForMacro[A] | |
} | |
class PrintForMacros(val c: Context) { | |
import c.universe._ |
macro di { | |
case { | |
_(function ($args (,) ...) { | |
$body... | |
}) | |
} => { | |
letstx $names... = _.map( | |
#{ $args... }, | |
function(ident) { | |
return makeValue(ident.token.value, ident); |
trait DatabaseLayer { | |
def dependency: Int | |
} | |
trait ConcreteDatabaseLayer extends DatabaseLayer { | |
def dependency: Int = 100 | |
} | |
trait DatabaseResource1 { | |
this: DatabaseLayer => |
sealed trait PhpValue { | |
def \(field: PhpValue): Seq[PhpValue] = Seq.empty[PhpValue] | |
def \\(field: PhpValue): Seq[PhpValue] = Seq.empty[PhpValue] | |
} | |
sealed trait PhpArrayLike extends PhpValue { | |
def fields: Map[PhpValue, PhpValue] | |
override def \(field: PhpValue): Seq[PhpValue] = | |
fields.toSeq.collect { |
/* ===== NOTE ===== | |
* | |
* This code sample is out-of-date! | |
* | |
* If you're looking for support for shapeless HLists in Slick queries, | |
* check out [Slickless](https://github.com/underscoreio/slickless). | |
* | |
* ================ | |
*/ | |
import slick.driver.MySQLDriver.simple._ |
#!/usr/bin/env bash | |
git checkout master | |
git branch -D nohistory | |
for branch in `git branch | cut -c2-` | |
do | |
echo "========== $branch ==========" | |
git checkout $branch | |
git branch -D nohistory |
lazy val chat = project.in(file(".")).enablePlugins(PlayScala) | |
scalaVersion in chat := "2.11.4" | |
libraryDependencies in chat ++= Seq( | |
jdbc, | |
anorm, | |
"org.postgresql" % "postgresql" % "9.3-1101-jdbc4", | |
"org.webjars" % "bootstrap" % "3.0.2", | |
"org.scalatestplus" %% "play" % "1.2.0" % "test" |
/* | |
Overview | |
-------- | |
To run a query using anorm you need to do three things: | |
1. Connect to the database (with or without a transaction) | |
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator | |
3. Call one of the methods on `SqlQuery` to actually run the query |
def userId(username: String): Option[Int] = | |
Some(1) | |
def mostRecentOrderId(userId: Int): Option[Int] = | |
Some(2) | |
def orderCost(orderId: Int): Option[Int] = | |
Some(3) | |
def mostRecentOrderCost(username: String): Option[Int] = |