github.com/mattn/anko@v0.1.10/_example/scripts/example.ank (about)

     1  #!anko
     2  
     3  # declare function
     4  func foo(x){
     5    return x + 1
     6  }
     7  
     8  func bar(x ...){
     9    return len(x)
    10  }
    11  
    12  # declare variables
    13  x = 1
    14  y = x + 1
    15  
    16  # print values 
    17  println(x * (y + 2 * x + foo(x) / 2))
    18  
    19  # if/else condition
    20  if foo(y) >= 1 {
    21    println("こんにちわ世界")
    22  } else {
    23    println("Hello, World")
    24  }
    25  
    26  # array type
    27  a = [1,2,3]
    28  println(a)
    29  println(a[2])
    30  println(len(a))
    31  
    32  # map type
    33  m = {"foo": "bar", "bar": "baz"}
    34  for k in keys(m) {
    35    println(m[k])
    36  }
    37  
    38  f = func(a) {
    39    println(a)
    40  }
    41  
    42  f("あんこ")
    43  
    44  f = func(a ...) {
    45    println(a)
    46  }
    47  
    48  f("あんこ", "だいすき")
    49  
    50  println(1 && 2)
    51  
    52  println(bar(1,2,3))
    53  println("foo")
    54  println(toByteSlice("あいう"))
    55  println(toRuneSlice("あいう"))
    56  
    57  a = 1
    58  func foo() {
    59    a = 2
    60  }
    61  foo()
    62  println(a)
    63  
    64  module Foo {
    65    func bar1() {
    66      println("Foo.bar1")
    67    }
    68  }
    69  
    70  println(Foo.bar1())