Skip to content

Instantly share code, notes, and snippets.

def isSorted[A](as: List[A], gt: (A, A) => Boolean): Boolean = as match {
case a :: b :: tail => {
if (!gt(a, b)) return false
isSorted(b :: tail, gt)
}
case _ => true
}
package pl.edu.agh.openshop
import pl.edu.agh.openshop.utils.fastfor
package object utils {
def fastfor(limit: Int)(f: Int => Unit) {
var i = 0
while (i < limit) {
f(i)
function _extend(object, source) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
object[key] = source[key];
}
}
return object;
}
function _with() {
var mtv = (function (mtv) {
'use strict';
mtv.TraitA = function (self) {
self.functionA = function () {
console.log('[start]: TraitA.functionA');
console.log(self.getModel());
console.log('[end]: TraitA.functionA');
};
def foo: String = ???
def bar(): String = ???
1 + 3 == (1).+(3)
!true == true.unary_!
case class User(name: String, lastname: String)
User(name = "Michal", lastname = "Kowol") == User(lastname = "Kowol", name = "Michal") // true
package com.michal
class A {
private def defaultPrivate = ???
private [this] def superPrivate(other: A) {
//other.superPrivate(this) // error
other.defaultPrivate
superPrivate(other)
}
private [michal] def publicInPackage = ???
case class User(name: String, age: Int)
User(name = "Bob", age = 10).copy(age = 40) // User(Bob, 40)
val s = Array(1 ,2, 3) // s: Array[Int] = Array(1, 2, 3)
def testCase(s: Seq[Int]) = s // testCase: TestCase[](val s: Seq[Int]) => Seq[Int]
testCase(s) // res0: Seq[Int] = WrappedArray(1, 2, 3)
s(0) = 7 // res1: Unit = ()
testCase(s) // res2: Seq[Int] = WrappedArray(7, 2, 3)