In Python, I can get the length of a rundown by calling its __len__ strategy. __len__ isn't characterized on every individual rundown protest, however on the rundown class. The technique can be gotten to straightforwardly through the class:
>>> [].__len__()
0
>>> type([])
<class 'list'>
>>> list.__len__([])
0
Be that as it may, the comparable code does not work in
Ruby:
> [].length
=> 0
> [].class
=> Array
> Array.length([])
NoMethodError: vague strategy `length' for Array:Class
For what reason can the length strategy not be discovered when utilizing Array.length? Does strategy query in Ruby work uniquely in contrast to Python?
برچسب:
نویسنده: آیلین رضوانی
تاريخ: پنجشنبه
30 آذر
1396 ساعت: 23:15