Is there a way to do this? (possibly Ruby related)

Hi,
Sonic Pi Newbie here
Ive used the **args trick that I found to be able to get all the arguments to a define like this:
define :chord_player do |root, type, repeats, length, **args|

What I was wondering (since there doesnt seem to be any concept of strings)
one of the args will be say ‘release:4’
Because of the nature of the define, one of may main arguments (repeats) I have currently inserted because I cant seem to find a way of grabbing the ‘4’ from ‘release:4’
Alternatively, is there a way of creating ‘release:4’ from within the define as I already know the 4 is passed as the repeats argument.

I hope I have explained myself sufficienly :slight_smile:
Cheers,

Hello @lwh56, welcome!

It might help to show how you would be expecting to call the function - eg, are you saying it might be called like this?:

chord_player(:a4, :minor, 4, 8, 'release:4')

Like Ethan not sure exactly about your example, but here is one which lets you extract a value for release.

define :test do |synth,note,**args|
  puts synth,note, args[:release]
  synth synth,note: note,release: args[:release]
end
test :saw,72,release: 4

If you omit :release arg it will use nil but still work.

That looks promising, i will check it out and get back to you. Thanks

Yes, so all I really needed to know is the construct like:
sleep(args[:release])
ie a way to extract the argument and use it elsewhere. Pretty trivial now I see it!
Thanks