Skip to content

Instantly share code, notes, and snippets.

public class Main {
public static void main(String[] args) {
Integer a = 500;
Integer b = 500;
System.out.println(a == b);
Integer c = 100;
Integer d = 100;
import util.Random
type Point = (Int, Int)
case class Direction(dir: Int) {
require(dir >= 0 && dir < 4)
def left = Direction((dir + 3) % 4)
def right = Direction((dir + 1) % 4)
def flip = Direction((dir + 2) % 4)
case class Trie[T <: Iterable[_]](
content: T = T.empty,
chlds: Map[Char, Trie[T]] = Map().withDefaultValue(Trie[T]())
) {
override def toString =
content + chlds.map {
case (k, v) => s"k: v"
}.mkString
def update(s: String, f: T => T): Trie[T] =
var users = Map.empty[Int, Set[ActorRef]]
def receive = {
case AddUser(id) => {
users += id -> users.lift(id) match {
case None => Set(sender)
case Some(prev) => prev + sender
}
}
}
val s = List((1,1,10),(2,3,2))
println({ val r = 2; val c = 3
s.collectFirst {
case (r, c, x) => x
}
})
case class T(val ops: Seq[Int])
object T {
def apply(ops2: Int*): T = T(ops2)
}
println(T(List(1,2,3)).ops)
println(T(1,2,3).ops)
def self.intersect_segment_segment(line1,line2)
if result.desc == :line_array
case ref_pts.length
when 4
# ----- vvvv SECTION TO COMMENT vvv -----
if line1.include?(ref_pts[1]) && line1.include?(ref_pts[2])
PGL_Intersect.new :line,[ref_pts[1],ref_pts[2]]
else
PGL_Intersect.new :normal, []
How to record the *object* from which class was instantiated?
class C
def parent
# stub!
end
end
class P
def spawn
class Rubko::Asset < Rubko::Controller
def initialize(*)
p 'Asset init'
super
end
end
class FilesController < Rubko::Asset
def work
# some I/O and Net calls
end
100.times {
EM.add_timer(rand 10) {
work
}
}