C#
delegate int del(int i);
static void Main(string[] args)
{
del myDelegate = x => x * x;
int j = myDelegate(5); //j = 25
}
Java
public class ThreadTest {
public static void main(String[] args) {
Runnable r1 = new Runnable() {
@Override
public void run() {
System.out.println("Old Java Way");
}
};
Runnable r2 = () -> { System.out.println("New Java Way"); };
new Thread(r1).start();
new Thread(r2).start();
}
}
Objective-C
double (^multiplyTwoValues)(double, double) =
^(double firstValue, double secondValue) {
return firstValue * secondValue;
};
double result = multiplyTwoValues(2,4);
NSLog(@"The result is %f", result);