Add to `doc/limitations.md` about `nil?` redefinition; ref 4996709 [ci skip]
KOBAYASHI Shuji
4 years ago
125 | 125 | true |
126 | 126 | ``` |
127 | 127 | |
128 | ## defined? | |
128 | ## `defined?` | |
129 | 129 | |
130 | 130 | The `defined?` keyword is considered too complex to be fully |
131 | 131 | implemented. It is recommended to use `const_defined?` and |
185 | 185 | ` 'ab' ` |
186 | 186 | Behavior of the operator wasn't changed. |
187 | 187 | |
188 | ## Kernel#binding is not supported | |
188 | ## `Kernel#binding` is not supported | |
189 | 189 | |
190 | 190 | `Kernel#binding` method is not supported. |
191 | 191 | |
237 | 237 | from the default expression of optional arguments and keyword arguments, |
238 | 238 | since actual assignment is done after the evaluation of those default |
239 | 239 | expressions. Thus: |
240 | ||
240 | ||
241 | 241 | ```ruby |
242 | 242 | def f(a,(b,c),d=b) |
243 | 243 | p [a,b,c,d] |
246 | 246 | ``` |
247 | 247 | |
248 | 248 | CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`. |
249 | ||
250 | ## `nil?` redefinition in conditional expressions | |
251 | ||
252 | Redefinition of `nil?` is ignored in conditional expressions. | |
253 | ||
254 | ```ruby | |
255 | a = "a" | |
256 | def a.nil? | |
257 | true | |
258 | end | |
259 | puts(a.nil? ? "truthy" : "falsy") | |
260 | ``` | |
261 | ||
262 | Ruby outputs `falsy`. mruby outputs `truthy`. |