...
1using Toybox.Application as App;
2using Toybox.System;
3
4const PI = 3.14;
5
6class MyProjectApp extends App.AppBase {
7 protected var y;
8
9 function initialize () {
10 me.y = "Hello";
11 self.y = "World";
12 var x = add( 3, 4 );
13 var array = new [x];
14
15 // Initialize the sub-arrays
16 for( var i = 0; i < x; i += 1 ) {
17 array[i] = new [5];
18 }
19
20 var dict = { "a" => 1, "b" => 2 };
21 var person = { :firstName=>"Bob", :lastName=>"Jones" };
22 }
23
24 public function onStart(state) {
25 var v = new Foo();
26 var m = v.method(:op);
27 m.invoke(1,2l);
28 }
29
30 function getInitialView() {
31 return [ new MyProjectView() ];
32 }
33
34 function add( a, b ) {
35 return a + b;
36 }
37
38 function thisFunctionUsesAdd() {
39 var a = add( 1, 0x03f ); // Return 4
40 var b = add( "Hello ", "World" ); // Returns "Hello World"
41 }
42
43}
44
45class Foo {
46 function op(a, b) {}
47}
View as plain text