Support

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

For general discussion related FlowStone

Ruby Anomaly

Postby DaveyBoy » Wed Nov 13, 2019 12:42 am

Hi Guys

Just noticed the following Ruby anomaly:

Image

.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?
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Ruby Anomaly

Postby RJHollins » Wed Nov 13, 2019 2:06 am

in the first example ... if you use to_b get the same error.

will follow this 8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: Ruby Anomaly

Postby tulamide » Wed Nov 13, 2019 2:32 am

RJHollins wrote:if you use to_b get the same error.
There is no #to_b in Ruby

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?
Yes, because DSPR did a dirty work while programming the method.

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

Postby DaveyBoy » Wed Nov 13, 2019 7:31 pm

thanks for the explanation Tulamide . . I wouldn't have thouight of that.
Talking about OCD, heres a small example of mine:

Image

:D
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Ruby Anomaly

Postby tulamide » Thu Nov 14, 2019 2:44 am

DaveyBoy wrote:Talking about OCD, heres a small example of mine:
:D
OMG! We're brothers in spirit! :lol:
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany


Return to General

Who is online

Users browsing this forum: No registered users and 60 guests