Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

Variables and base types

dangreen edited this page Jan 2, 2015 · 6 revisions

Variables definition

You can define vars with any type (yet without checking).

var num = 1;               // valid JavaScript
int i, j = 3;
String str = "someString"; // yes, you can use ` quotes

Exists possibility to define object's property:

num myProfile.age = 19;

Also you can mark definition with modificators:

const myProfile.age = 10;

list of modificators:

  • const to define constant
  • covert to define unenumerable property (not var)
  • export to export var or property from module

Variables assignment

In ColaScript you can use follow syntax to reduce object filling:

String name = "Felix";
int age = 3;
String about = "Black'n'white sly cat.";
	
Object info = { name, age, about };

Also you can use destructuring assignment:

int a = 2, b = 3;
		
[a, b] = [b, a];                                      // swap
{ name, age, about, friends : [firstFriend] } = info; // with object
[firstSkill, ..., lastSkill] = skills;                // with array

Boolean aliases

In ColaScript, like in CoffeScript, exists boolean aliases:

yes == true && on  == true;
no == false && off == false;	
Clone this wiki locally