Skip to content

Instantly share code, notes, and snippets.

@ceylonwebide
ceylonwebide / conditions.ceylon
Created September 26, 2015 18:18
EXAMPLE: Conditions and assertions
//$webrun_wrapped
shared void run() {
//You can use normal conditions as in any other language
value nums = 1..10;
if (nums.size == 10) {
print("ok, normal condition");
}
if (nums.size == 10 && nums.first == 1) {
print("another normal condition");
}
@ceylonwebide
ceylonwebide / null_and_union.ceylon
Created September 26, 2015 18:17
EXAMPLE: Null values and union types
//$webrun_wrapped
shared void run() {
// The following is an error because null is not a String.
//String s = null; //ERROR!
// We have to write "String?" instead:
String? s1 = null;
String? s2 = "This is a String.";
print(s1);
@ceylonwebide
ceylonwebide / basics.ceylon
Created September 26, 2015 18:12
EXAMPLE: Basics
//$webrun_wrapped
shared void run() {
// Any object can be converted to a string using ".string".
// There are no special primitive types, even numbers are objects.
Integer i = 3;
String s = i.string;
"Declarations can be documented using the `doc` annotation.
Note that string literals can span several lines."
Boolean b = (i == 3);
@ceylonwebide
ceylonwebide / hello_world.ceylon
Last active March 12, 2021 13:26
EXAMPLE: Hello World
//$webrun_wrapped
shared void run() {
// The classic "hello world" in Ceylon
print("Hello world!");
// Click 'Run' above to run the program.
// It is compiled to JavaScript and then runs directly in your browser!
// You can try the more examples from the list on the right of this page
@ceylonwebide
ceylonwebide / index.json
Last active September 26, 2015 18:43
IMPORTANT: Official Ceylon Web IDE Examples
{
"sets": [
{
"title": "Try out a sample:",
"items": [
{
"title": "Hello World",
"gist": "1b5a174b7fda6eb0e3a6"
},
{