📜  关于 ruby 的重要主题 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:03.607000             🧑  作者: Mango

代码示例1
1.You can use ruby modules as mixins where your design requires multiple inheritance
2.Every method returns the value of its last statement as the value of the method though you can use return where you want to be more explicit.
3.You can open any class again and add methods to it, called monkey patching which can be very powerful if used sensibly otherwise hell will break.
4.You can pass a block of code to any method and operate on it, e.g. in ruby world most of the time coders use iterators instead of for loops.
5.Where possible use symbols instead of strings because they are efficient, e.g. in hash keys
etc..