Skip to content

v2.0.0-alpha60

Pre-release
Pre-release
Compare
Choose a tag to compare
@pachanga pachanga released this 19 Aug 12:47
· 1438 commits to master since this release

Maps foreach and json-alike initialization support

foreach(string k,int v in m) {
  …
}
[string]int m = {“Bob” : 42, “Sally” : 69}  

Nested classes

     class Bar {
        class Foo {
           int f
           func int getF() {
             return this.f
           }
        }
    }
     
    Bar.Foo foo = {f: 1}
    foo.getF()

Nested class interfaces

     class Bar {
        interface IFoo {
          func int foo()
        }
      }

      class Foo : Bar.IFoo {
        func int foo() {
          return 1
        }
      }   

Nested class enums

     class Bar {
         enum E {
           E1 = 1
           E2 = 2
         }
         func E getEnum() {
           return E.E2
         }
      }

      Bar bar = {}
      int what = (int)Bar.E.E1 + (int)bar.getEnum() 

Static class fields and methods

     class Bar {
        static int bar
        func static int foo() {
          return 42
        }
      }

     Bar.bar = 14
     int sum = Bar.bar + Bar.foo()

Variadic function arguments

   func int sum(...[]int ns) {
      int s = 0
      foreach(int n in ns) {
        s += n
      }
      return s
    }

  sum(1, 2, 3)
  sum(...[1, 2, 3])