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

**URL:** <https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379>\
**Category:** Support, Help & Resources\
**Created:** [January 9, 2022, 2:14pm UTC](https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379 "2022-01-09T14:14:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lwh56](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@lwh56](https://in-thread.sonic-pi.net/u/lwh56)\
**Post date:** [January 9, 2022, 2:14pm UTC](https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379/1 "2022-01-09T14:14:34Z")

</div>

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 🙂  
Cheers,

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [January 9, 2022, 2:24pm UTC](https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379/2 "2022-01-09T14:24:42Z")

</div>

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?:

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

```

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [January 9, 2022, 2:39pm UTC](https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379/3 "2022-01-09T14:39:59Z")

</div>

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

```ruby
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.

---

<div class="post-metadata">

**Author:** ![lwh56](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@lwh56](https://in-thread.sonic-pi.net/u/lwh56)\
**Post date:** [January 9, 2022, 2:44pm UTC](https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379/4 "2022-01-09T14:44:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lwh56](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@lwh56](https://in-thread.sonic-pi.net/u/lwh56)\
**Post date:** [January 9, 2022, 3:08pm UTC](https://in-thread.sonic-pi.net/t/is-there-a-way-to-do-this-possibly-ruby-related/6379/5 "2022-01-09T15:08:03Z")

</div>

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
