-
Objects
An object in programming is like a container that holds things. It can be used to store information like a box can store toys. For example, we could create an object called "cat" and it could have different pieces of information inside it like the cat's name, its color, or even how many lives it has left. Objects help us keep track of all the pieces of information we need for a program.
-
-
Map, Dictionary, Variable Objects
import std.stdio : writeln;
import std.string;
import std.conv;

void main()
{
	string[string] person = [
		"name": "John",
		"age": "36"
	];

	writeln(person["name"]); // John
	writeln(to!int(person["age"])); // 36
}

-
-
-
Class Objects
import std.stdio : write, writeln;
import std.string;

class Person {
	string name;
	int age;

	this(string name, int age) {
		this.name = name;
		this.age = age;
	}

	void greet() {
		write("Hello my name is ", this.name);
	}
}

void main()
{
	Person human = new Person("John", 36);

	writeln(human.name); // John
	writeln(human.age); // 36
	human.greet(); // Hello my name is John
}

-
-