gracekrcx / weekly-notes

4 stars 0 forks source link

(筆記)區分 Methods and Functions #127

Open gracekrcx opened 2 years ago

gracekrcx commented 2 years ago

method

The method is a function associated with an instance of class (object). The method is just a function declared inside a type (class/struct/enum) (上句的 type 是指 Swift 的 type) 結論:以 js 來說,在 class 內宣告的 function,稱為 method 呼叫方式: js 中的 method ,比較好聯想的是 js Built-In Methods, 例如:string 就會有 toLowerCase() 的 method, array 就會有 filter(), 物件導向的思考

function

A function is a piece of code that is called by name. 結論:以 js 來說,宣告在 class 外的 functions 就是 function 呼叫方式:在 call function 時可以帶入需要的 arguments

reference

GiveMePasS's Android惡補筆記 ios_dev_alb Methods and Functions

gracekrcx commented 2 years ago

Concepts of functional programming - What is a pure function?

之前完全沒有接觸的點 在 what is functional programming 的最後一點 『No iteration. Operations are done by recursion』