Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midi events: values assigned to two variables (syntax query) #3351

Open
jonnyhotchkiss opened this issue Nov 2, 2023 · 2 comments
Open

Midi events: values assigned to two variables (syntax query) #3351

jonnyhotchkiss opened this issue Nov 2, 2023 · 2 comments

Comments

@jonnyhotchkiss
Copy link

/midi:nanokey2_keyboard:0:1/note_on [53, 102]

note, velocity = sync "/midi:nanokey2_keyboard:0:1/note_on"

I've just found this info, and wanted to query the syntax.

Assume the first and second values are accessed via 'index' eg :0 and :1

I kind of expected another semi colon, to indicate in the assignment statement which values are assigned to which var (note and Velocity)

Is this standard ruby, or is someone able to further breakdown what's going on here?

Many thanks!

@nicoder
Copy link
Contributor

nicoder commented Nov 2, 2023

it looks like array destructuring (but I don't know what the sync function returns, or much Ruby)

$ irb
irb(main):001:0> a, b = [1, 2]
=> [1, 2]
irb(main):002:0> a
=> 1
irb(main):003:0> 2
=> 2

maybe this article can help: https://dev.to/ridhwana/destructuring-in-ruby-53j0

@rbnpi
Copy link
Contributor

rbnpi commented Nov 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants