package com.winterbe.java8.samples.lambda;

/**
 * @author Benjamin Winterberg
 */
public class Lambda4 {

    static int outerStaticNum;

    int outerNum;

    void testScopes() {
        int num = 1;

        LambdaToInterface.Converter<Integer, String> stringConverter =
                (from) -> String.valueOf(from + num);

        String convert = stringConverter.convert(2);
        System.out.println(convert);    // 3

        LambdaToInterface.Converter<Integer, String> stringConverter2 = (from) -> {
            outerNum = 13;
            return String.valueOf(from);
        };

        String[] array = new String[1];
        LambdaToInterface.Converter<Integer, String> stringConverter3 = (from) -> {
            array[0] = "Hi there";
            return String.valueOf(from);
        };

        stringConverter3.convert(23);

        System.out.println(array[0]);
    }

    public static void main(String[] args) {
        new Lambda4().testScopes();
    }

}
@@ -196,17 +196,16 @@
 um = 1;%0A
-%0A
         
@@ -421,32 +421,35 @@
   // 3%0A%0A        
+%0A%09%09
 LambdaToInterfac
@@ -580,32 +580,126 @@
 m);%0A        %7D;%0A%0A
+        stringConverter2.convert(23);%0A        System.out.println(outerNum);%0A        %0A        %0A
         String%5B%5D

add code