A common problem I run into when coding is dealing with the limited object types of a particular language. Hopefully a yearly compilation of all these snippets can provide a script that expands languages to what they should have had in the first place.
I can’t take credit from this one, but I think the guys at Hummingbird had something right with their recursive sum function for arrays. This function simply sums the numbers in an array.
After writing writing my fair share of for-loops, I decided there must be a better way to repeat a string. Personally, I found this solution to be very elegant and hopefully will help you as much as it helped me.
Here is a quick one for you today. Ever just want a simple way to see if there is an item in an array? Well fear not, this little snippet is to the rescue!