Does Ruby have a concept of an indexer method, for example, in C #?
Yes, a method named []takes one argument:
[]
>> class Foo >> def [](idx) >> idx * 5 >> end >> end => nil >> ?> f = Foo.new => #<Foo:0x101098d80> >> f[8] => 40 >> f[1] => 5
If you need to set the value in the index, name the method []=.
[]=
Source: https://habr.com/ru/post/1781823/More articles:touchesEnded: withEvent: not being called from my UIView that sits on top of the UITableView - iosGet the contents of a web page from Firefox in a C # program - c #Make resharper ignore code suggestions for specific projects - .netstore dates in oracle - sqlConfigure automatic creation of Post Slug in Wordpress - phpMultilingual iPhone apps with various integrated video, audio content - iosHow to access IR (infrared receiver) using Cocoa? - objective-cIs there a way to find out if a property or variable is set? - variablesHow to remove a user in MSCRM 4.0 - dynamics-crmHow to hide sender email address using phpmailer? - phpAll Articles