Default values ..copy that

“number Zero wall signage” by Bernard Hermant on Unsplash

Making reasonable arguments

def paint(color = "blue", tint = 0):
...
There are aspects I do like about javascript. Function argument semantics are not one of them.
function paint(color, tint) {
let color = color || "blue"
let tint = tint || 0
}
def paint(color: Color = Color.BLUE)(implicit tint: Tint) = Unit {
...
}

Comprehending though cohesion

fn paint(color: Color) {
...
}
paint(Color::default())
impl Default for Color {
fn default() -> Self {
Color::Blue
}
}

Changing semantic swim lanes

struct Coffee {
size: u16,
flavor: String
}
let grande_psl = Coffee {
size: 16,
flavor: "pumpkin spice latte".into()
};
let venti_psl = Coffee {
size: 20,
..grande_psl
};
#[derive(Default)]
struct Coffee {
size: u16,
flavor: String
}
let venti = Coffee {
size: 20,
..Default::default()
};
impl Coffee {
// Return a new sized coffee,
// not sure what kind yet
// I just know I need caffeine!
fn new(size: u16) -> Coffee {
Coffee {
size,
..Default::default()
}
}
}

Meetuper, rusting at sea, partial to animal shaped clouds and short blocks of code ✍

Meetuper, rusting at sea, partial to animal shaped clouds and short blocks of code ✍