12
Cyan101
7y

Coffee coffee = new Coffee { };
if ( coffee.Empty )
{
coffee.Refill ( );
}
else
{
coffee.Drink ( );
}
// I'm a software developer \\

Comments
  • 4
    Shouldn't coffe.Drink() be outside the else block?
  • 2
    @fasttime
    Shouldn't someone drink coffee, instead of coffee itself commiting an act of self-consumption?
  • 0
    let kofe = new CoffeeCup();
    kofe.on('empty',function(){
    this.refill();
    });
  • 0
    Gah the braces style
  • 1
    @GunBlade the point is coffee drink is a sort of absolute and should always be done, even when empty, we make sure to never have null by first checking coffee is filled or contains a value. Hence the refactoring to an if without an else. Because if it is about coffee there is no else. Ps edited to add apostrophes.
  • 0
    @fasttime should use case, with a fall through default.
  • 1
    @magicMirror case for a single case?
  • 1
    Should be a loop
  • 1
    I like the intention but technically speaking it's not correct. Coffee doesn't drink or refill itself.
Add Comment