Skip to content

Instantly share code, notes, and snippets.

@gkossakowski
Created August 24, 2011 17:16
Show Gist options
  • Save gkossakowski/1168581 to your computer and use it in GitHub Desktop.
Save gkossakowski/1168581 to your computer and use it in GitHub Desktop.
package com.google.gwt.sample.jribble.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
class Hello extends EntryPoint {
def onModuleLoad() {
val numbers = List(1, 2, 3, 4)
val strings = numbers map (_.toString + "...")
val a = foo(1)
val s = a.toList.toString
val b = new Button("Click me", (_: ClickEvent) => Window.alert("Hello, AJAX, said Scala\nThose numbers are coming from list!\n" + s));
RootPanel.get().add(b);
}
def foo[T: ClassManifest](x: T): Array[Array[T]] = foo2(Array.tabulate(2)(_ => x))
def foo2[T: ClassManifest](x: T): Array[T] = Array.tabulate(2)(_ => x)
implicit def clickHandler(f: ClickEvent => Unit): ClickHandler = new ClickHandler {
def onClick(event: ClickEvent) = f(event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment