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
int myFunction(int x) | |
{ | |
if (x > 10) | |
return x; | |
if (x < 10) | |
return x + 1; | |
if (x = 10) | |
return 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
value1 = if condition | |
# stuff | |
# stuff | |
true | |
else | |
# stuff | |
# stuff | |
false | |
end |
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 scala.language.implicitConversions | |
case class Optional[+T](value: Option[T]) | |
val omit = Optional(None) | |
implicit def valueToOptional[T](value: T): Optional[T] = Optional(Some(value)) | |
implicit def optionalToOption[T](opt: Optional[T]): Option[T] = opt.value | |
def add(a: Int, b: Optional[Int] = omit, c: Optional[Int] = omit): Int = |
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
// way faster than split2m | |
def split2f[T](list: Seq[T]): (Seq[T], Seq[T]) = { | |
val it = Iterator.iterate(true)(!_) | |
list.partition(_ => it.next) | |
} | |
// next approach, incredibly slow | |
// @TODO learn functional programming | |
def split2m[T](list: Seq[T]): (Seq[T], Seq[T]) = | |
list.foldLeft((Seq[T](), Seq[T]())) { | |
(tuple: (Seq[T], Seq[T]), element: T) => |
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 wandledi.java.Controller; | |
public class WandlediApp extends Controller { | |
public void index() { | |
getWriter().println("Hello World!"); | |
} | |
public static void main(String[] args) { | |
runStandAlone(true); |
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
implicit def trailingConditionals[T](any: => T) = new { | |
def provided(expr: Boolean) = if (expr) Some(any) else None | |
def unless(expr: Boolean) = if (!expr) Some(any) else None | |
} | |
implicit def verbosePlus(i: Int) = new { | |
def plus(j: Int): Int = { | |
println("Adding " + i + " and " + j); | |
i + j | |
} |
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
def form() { | |
<any name="author"/> merge <any value="Bobby"/> | |
// vs | |
get("name" -> "author").setAttribute("value", "Bobby") | |
// vs | |
<where name="author" setValue="Bobby"/>! | |
// vs | |
<any name="author"/> update { | |
"value" -> "Bobby" // [,\n"foo" -> "bar" ... | |
} |
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
def javaUsage() { | |
val model = new Model | |
model.onChange(new ChangeListener { | |
override def changed() { | |
// react | |
} | |
}) | |
} | |
def scalaUsage() { |
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
overriding method + in trait MapLike of type [B1 >: String](kv: (String, B1))scala.collection.mutable.Map[String,B1]; | |
[error] method + has incompatible type | |
[error] override def +[B1 >: String](kv: (String, B1)): Parameters = { | |
[error] ^ |
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
if(isComposite) { | |
_compositeKeyMembers.set(Some(new ArrayBuffer[SelectElement])) | |
println("set members to empty ArrayBuffer") | |
} | |
var res = proxy.invokeSuper(o, args); | |
if(isComposite) { | |
val ck = res.asInstanceOf[CompositeKey] | |
println("members before: " + ck._members) | |
ck._members = Some(_compositeKeyMembers.get.get.map(new SelectElementReference[Any](_)(NoOpOutMapper))) |
OlderNewer