DEV Community

Marko V
Marko V

Posted on

half glass full / half empty

Earlier today I heard this classic statement about a glass half full and I figured, can it be programmatically defined to represent the statement(s)?

Glass glassFilledWithLiquid = new Glass(new Liquid[250]);
Enter fullscreen mode Exit fullscreen mode

In C# you can initialize, at best, the size of the container to begin with before you can fill it. Meaning it has initial state of 0 and a desired state to be filled to the defined size of the array. So the directional and nominal state is to be filled. So it would be a glass half filled/full.

JS

var glass = [];

var secondGlass = [1,2,3,4,5,6];
Enter fullscreen mode Exit fullscreen mode

Now this looks, at first glance as if you can have an initial state of both empty and full BUT.... since it uses C++ in the actual V8 engine running the javascript stuff, it still requires initialization of an empty array before filling it. Sooo....

Conclusion

Any container's initial state is empty, and to be useful, it's desired state is to be filled meaning it's half-filled at the time it's at 50%.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay