If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby Anomaly
5 posts
• Page 1 of 1
Ruby Anomaly
Hi Guys
Just noticed the following Ruby anomaly:
.to_a works for a range but not for midi
and
.to_array works for midi but not for a range.
Does anybody know why this is?
Just noticed the following Ruby anomaly:
.to_a works for a range but not for midi
and
.to_array works for midi but not for a range.
Does anybody know why this is?
-
DaveyBoy - Posts: 131
- Joined: Wed May 11, 2016 9:18 pm
- Location: Leeds UK
Re: Ruby Anomaly
in the first example ... if you use to_b get the same error.
will follow this
will follow this
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Ruby Anomaly
There is no #to_b in RubyRJHollins wrote:if you use to_b get the same error.
Yes, because DSPR did a dirty work while programming the method.DaveyBoy wrote:.to_a works for a range but not for midi
and
.to_array works for midi but not for a range.
Does anybody know why this is?
Ruby knows two (and only two) array conversion methods: to_a (explicit conversion) and to_ary (implicit conversion).
When you create your own class, you are encouraged to hook into those. But DSPR ignored it and created a non-ruby-compatible method called to_array. Unfortunately it is confusing (as your post proves) and nothing we can change. We have to live with it, which triggers my perfection OCD. I'm sure, there are more of those language breaking lazy DSPR methods around.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Anomaly
thanks for the explanation Tulamide . . I wouldn't have thouight of that.
Talking about OCD, heres a small example of mine:
Talking about OCD, heres a small example of mine:
-
DaveyBoy - Posts: 131
- Joined: Wed May 11, 2016 9:18 pm
- Location: Leeds UK
Re: Ruby Anomaly
OMG! We're brothers in spirit!DaveyBoy wrote:Talking about OCD, heres a small example of mine:
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 60 guests