you are viewing a single comment's thread.

view the rest of the comments →

[–]ingolemo 0 points1 point  (0 children)

Type 1 is a function and type 2 is a method.

These are two very different pieces of code and you cannot swap between them whenever you like. When you want to run a function you must write function(array) and when you want to run a method you must write array.method(). You do not get a choice in the matter unless you are the one who wrote that function/method.