Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cioccarellia's full-sized avatar

Andrea Cioccarelli cioccarellia

View GitHub Profile
// Standard
val bob = Person("Bob", 19, "Texas")
println(bob)
bob.moveTo("Florida")
bob.incrementAge()
bob.alias = "Bravo"
println(bob)
// Using apply
val alice = Person("Alice", 19, "Italy").apply {
@cioccarellia
cioccarellia / ANSI-color-codes.h
Created February 4, 2021 16:29 — forked from RabaDabaDoba/ANSI-color-codes.h
The entire table of ANSI color codes working in C!
/*
* This is free and unencumbered software released into the public domain.
*
* For more information, please refer to <https://unlicense.org>
*/
//Regular text
#define BLK "\e[0;30m"
#define RED "\e[0;31m"
#define GRN "\e[0;32m"
val engineCount = 2
val planeEngines = EngineFactory.generateFaultyEngines(engineCount).also {
println(it)
}
planeEngines.getOrNull(engineCount - 1)?.let {
println(it.cruiseSpeed)
}
val mountain = Mountain().apply {
treeCount = randomBetween(2000, 3000)
houseCount = randomBetween(5, 10)
pendence = 20/100
roadKind = RoadKind.DIRT
}
val leavesToHouseRatio: Float = mountain.run {
val totalLeaves = treeCount * TREE_LEAVES_COUNT
val houseSurface = houseList.map {
val wall = PaintedWall()
wall.run {
val color = this.wallColor
paint.let {
println(it.color)
}
}
val wall = PaintedWall()
wall.run {
val color = this.wallColor
paint.run {
println(color)
}
}
paintBrush.run {
rollAndClean()
dipInto(yellowPaintBucket)
}
paintBrush.let {
it.rollAndClean()
it.dipInto(yellowPaintBucket)
}
paintBucket.apply {
fillWith(Color.LIME)
mix()
println(currentPaintColor)
}
paintBucket.run {
fillWith(Color.LIME)
mix()
println(currentPaintColor)
this
}