This file contains 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 Person(val firstName: String, val lastName: String, val age: Int, val email: String) { | |
def update(firstName: String = firstName, lastName: String = lastName, age: Int = age, email: String = email) : Person = { | |
Person(firstName, lastName, age, email) | |
} | |
} | |
val seedPerson = Person("A", "B", 1, "me@home.com") | |
println(seedPerson) | |
val updatedPerson = seedPerson update (age = 100, firstName = "Z") |
This file contains 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
package output | |
import javax.xml.bind.{ Marshaller, JAXBContext } | |
import javax.xml.bind.annotation._ | |
import javax.xml.bind.util.JAXBSource | |
import javax.xml.transform.Source | |
import javax.xml.ws.{ Endpoint, Provider, ServiceMode, WebServiceContext, WebServiceProvider } | |
import javax.xml.ws.http.HTTPBinding | |
import javax.xml.ws.handler.MessageContext | |
import javax.annotation.Resource |
This file contains 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
mvn archetype:generate -DarchetypeGroupId=org.scala-tools.archetypes -DarchetypeArtifactId=scala-archetype-simple | |
mvn compile | |
mvn exec:java -Dexec.mainClass="some.path.to.Main" -Dexec.args="arg0 arg1 arg2" |
This file contains 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
package org.scalabound.scatdd.scalacheck | |
import org.scalabound.scatdd.FizzBuzz | |
import org.scalacheck.ConsoleReporter.testReport | |
import org.scalacheck.Prop.forAll | |
import org.scalacheck.Prop.propBoolean | |
import org.scalacheck.ConsoleReporter | |
import org.scalacheck.Test | |
object FizzBuzzScalaCheck { |
This file contains 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
package org.scalabound.scatdd.specs2 | |
import org.scalabound.scatdd.FizzBuzz | |
import org.junit.runner.RunWith | |
import org.specs2.runner.JUnitRunner | |
// package unitTest { |> Scala IDE will not pick the class up as runnable if I sub-package it like this :-( | |
@RunWith(classOf[JUnitRunner]) | |
class FizzBuzzJUnitSpec extends org.specs2.mutable.Specification { | |
This file contains 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
package org.scalabound.scatdd.scalatest | |
import org.junit.runner.RunWith | |
import org.scalatest.FunSpec | |
import org.scalatest.junit.JUnitRunner | |
import org.scalabound.scatdd.FizzBuzz | |
@RunWith(classOf[JUnitRunner]) | |
class FizzBuzzScalaTest extends FunSpec { |
This file contains 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
// Idiomatic solution using extrators | |
// Extractors allow us to bind parameters to an object and are usable in pattern matches to see if a pattern can apply to the params submitted. | |
// Note this is simialr to case classes, but works against an Object (which are like 'static' classes in Java). Also it incurs some performance penalties | |
// as opposed to using case classes | |
class BowlingForExtractors() { | |
def score(bowls:List[Int]) = scoreFrames(bowls).slice(0,10).sum // take the first 10 elements from the List and sum them..any additional elements are the result of additional strikes | |
def scoreFrames(bowls:List[Int]) : List[Int] = bowls match { | |
case Nil => List(0) |
This file contains 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 javax.jws.WebService | |
import javax.jws.soap.SOAPBinding | |
import javax.jws.soap.SOAPBinding.Style | |
import javax.xml.ws.Endpoint | |
@WebService(targetNamespace="org.scalabound.test", name="org.scalabound.test", portName="test", serviceName="WSTest") | |
private class MinimalSoapServer { | |
@SOAPBinding(style = Style.RPC) | |
def test(value : String) = "Hi " + value |
This file contains 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
package org.scalabound.scatdd | |
object FizzBuzz { | |
def eval(x: Int) = (x % 3, x % 5, x) match { | |
case(0, 0, _) => "FizzBuzz" | |
case(0, _, _) => "Fizz" | |
case(_, 0, _) => "Buzz" | |
case _ => "" + x | |
} |
This file contains 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
package org.scalabound.scatdd; | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
import org.scalabound.scatdd.FizzBuzz; | |
public class FizzBuzzJUnitTest { |
OlderNewer