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.wellnr.commons.scala.models.EnumerationWithClassName.{BaseType, EnumerationCapabilities} | |
| sealed trait Farbe extends BaseType | |
| object Farbe extends EnumerationCapabilities[Farbe] { | |
| case object Rot extends Farbe | |
| case object Gelb extends Farbe | |
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 ApplyMethod extends App { | |
| case class Centimeter(i: Double) { def meter = Meter(i / 100); def m = meter } | |
| case class Meter(i: Double) | |
| implicit class IntHelper(val i: Double) extends AnyVal { | |
| def m = Meter(i) | |
| def cm = Centimeter(i) |
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
| implicit class MyInt(i: Int) { def doSomethingCool = ??? } | |
| 42.doSomethingCool |
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
| package com.ibm.fp.scala | |
| import language.implicitConversions | |
| object LazyEvaluation extends App { | |
| def trivial = { | |
| val max = 5 |
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 DeclarativeLanguage extends App { | |
| final case class Employee(firstname: String, lastname: String, department: String, salary: Int, ismanager: Boolean) | |
| val employees = List( | |
| Employee("Joe", "Smith", "Sales", 50000, false), | |
| Employee("Suzanne", "Harrison", "Sales", 40000, false), | |
| Employee("Mary", "Jones", "Sales", 100000, true), | |
| Employee("Ben", "Simpson", "Accounting", 90000, true), | |
| Employee("Paul", "Miller", "Accounting", 25000, false)) |
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
| package com.ibm.fp.scala | |
| object PatternMatching extends App { | |
| sealed trait Expression | |
| sealed trait UnaryExpression extends Expression { val unary: Expression } | |
| sealed trait BinaryExpression extends Expression { val left: Expression; val right: Expression } |
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
| // === AND.java === | |
| package com.ibm.fp.java.patternmatching; | |
| public final class AND extends BinaryExpression { | |
| public AND(Expression left, Expression right) { | |
| super(left, right); | |
| } | |
| } |
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
| package de.michaelwellner.edu.file; | |
| import java.io.BufferedInputStream; | |
| import java.io.BufferedOutputStream; | |
| import java.io.File; | |
| import java.io.FileInputStream; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.OutputStream; |
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
| package de.michaelwellner.edu.forkjoin; | |
| import java.util.concurrent.ForkJoinPool; | |
| import java.util.concurrent.RecursiveTask; | |
| public class ForkJoin { | |
| private static final boolean DEBUG = false; | |
| private static class Fibonacci { |
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
| package de.michaelwellner.edu.stringswitch; | |
| public class StringSwitch { | |
| private static final String HALLO = "Hallo"; | |
| private static final String GUT = "Gut"; | |
| private static final String SCHOENEN_TAG = "Schönen Tag noch!"; | |
| private static final String CIAO = "Ciao"; | |
| private static final String TSCHUESS = "Tschüss"; |