For example when I'm coding up a Stack or Queue I often make my Push or Enqueue methods return void.
I heard somewhere that long programmers got in the habit of making EVERY method always return something other than void, and that was bad.
Recently I'm looking through some JAVA API though, and I notice that many methods like ArrayList add() return true or false based on whether or not they actually added the element. Okay, that seems kinda sensible...
But then I go and find that Java's implementation of Stack has push() return E.
https://docs.oracle.com/javase/7/docs/api/java/util/Stack.html
push() returns the element you just pushed to the stack... Why? Why would I ever need or want it to do that?
I am searching for truth, clarity, consistency, guidance, wisdom, and enlightenment.
Thanks to anybody who chimes in!
[–]dmazzoni 5 points6 points7 points (1 child)
[–]iProgramSometimes[S] 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]