DEV Community

loading...

half glass full / half empty

omnoms profile image Marko V ・1 min read

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]);

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];

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%.

Discussion

pic
Editor guide