Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
That's Python, not Ruby, and it does need return to work.
Thanks, I did mine like this and wasn't sure about it.
at w3schools there is lot
Note that although this works, this is not best practice as a new copy of the bark method will be created for each instance, rather than sharing a single instance of the bark method via inheritance. No inheritance is being utilized here. So it results in unnecessary extra memory usage.
I agree with @cbalci and @igandecki. A single loop that iterates the array once is faster than looping the array multiple times.
You don't actually need "return", not that it hurts to have it in there. Ruby automatically returns the last line of code.
This comment is hidden because it contains spoiler information about the solution
Comparing 'for loop' to 'indexOf' is not the correct analysis here. The above solution goes throught the remaining list every time it removes an item. @Igandecki's point is fair. A single pass solution can be more efficent than this one.
Very interesting, I have no idea how this could possibly be true.. I will have to investigate. :)
Thanks!
@Igandecki
Time complexity is bounded by indexOf and splice which is the fastest way since we dont have to iterate through the array completely. Strangly even doing indexOf multiple times is faster than interating through the array completely. So it's the best way to do it.
source: http://jsperf.com/js-for-loop-vs-array-indexof/8
How is this voted up for the best practice?
It's nice to read and very short, let's even say "clever", but, it makes you go through the array multiple times - every time you run indexOf().
Very inefficient.
I know this must be a horrible way of coding this. Can someone give me some insight on how to improve this code I really want to understand how an expert sees code and optimizes it.
I'm a little confused with this syntax why have a ?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...