Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Something else: if you initialize a new coffee it will always be the same thing, no need to check with an if statement.
-
@Codex404 It depends on constructor. It could have conditions that sometimes fill it with coffee.
-
I like how the coffee refills itself and the useless property reference at the end.
-
@ThreadRipper
Naming conflict? Depends on the language
Line 3 could be a getter where drink is clearly an action and thus should be a method/function. -
Root824806ySo many issues.
1) It overwrites the coffee class.
2) Initialized coffee should already have coffee.
3) `coffee.drink` would return the function, not execute it.
4) Without a loop, you can only drink or refill the coffee, once, and never both.
5) Put a space between an if and its condition, please!
6) Indentation! Now!
7) 5/6 lines could be shortened to a ternary.
let contents = new Coffee();
while (Coffee) {
(contents.empty ? contents.refill() : contents.drink());
}
Related Rants
When even the gift mug you got from your coworkers has a bug in the code...
rant
devlife