Dylan Cheatsheet
Unique Features
- Object-oriented language
- Strongly typed with optional type inference
- Supports multiple dispatch
- Garbage collection
- Mixins for code reuse
- Syntax inspired by Lisp and C
Variables
define variable_name = value;
Functions
define method_name(parameter1: type1, parameter2: type2): return_type => {
// Function body
}
method_name(argument1, argument2);
Loops
// While loop
while condition do {
// Loop body
}
// For loop
for variable_name in range do {
// Loop body
}
// Each loop
each(item in collection) {
// Loop body
}
Conditionals
// If statement
if condition then {
// Code to execute if condition is true
}
// If-else statement
if condition then {
// Code to execute if condition is true
} else {
// Code to execute if condition is false
}
// Case statement
case variable_name in
value1 => {
// Code to execute if variable_name equals value1
}
value2 => {
// Code to execute if variable_name equals value2
}
_ => {
// Code to execute if variable_name does not equal any of the values
}
end;
File Manipulation
// Reading from a file
let file_contents = file.read("file_name");
// Writing to a file
file.write("file_name", "text to write");
Resources