# How to get rid of quotation marks for splatting array of arguments?

**URL:** <https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497>\
**Category:** Support, Help & Resources\
**Created:** [May 5, 2021, 5:41am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497 "2021-05-05T05:41:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![blipson](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/blipson/32/1772_2.png) [@blipson](https://in-thread.sonic-pi.net/u/blipson)\
**Post date:** [May 5, 2021, 5:41am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/1 "2021-05-05T05:41:34Z")

</div>

This:

```ruby
x = ["amp:", 0.5, ", ", "release:", 0.2]
print *x

```

outputs this:

` "amp:" 0.5 ", " "release:" 0.2`

but I want it to output this:

` amp: 0.5 , release: 0.2`

I’ve looked at many solutions on the web, and none of them seems to work, for example [here](https://www.ruby-forum.com/t/removing-double-qoutes-from-a-string/244323/8). Can anyone advise how to eliminate those double quotes so I can splat arrays like this as parameters to `play`?

---

<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:** [May 5, 2021, 6:54am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/2 "2021-05-05T06:54:57Z")

</div>

I’ve done a bit of a cursory search on this myself, and don’t yet see any ways to do what you want.  
Granted I do not yet have the full picture, but it feels to me like there might be a better way to achieve your goal, (passing dynamic parameters to the `play` function?).

If you are not strictly limited to exactly the kind of data format that you show above, then one alternative example could be something like this:

```ruby
x = [[:amp, 0.5], [:release, 0.2]].to_h
play 60, x

```

It may be helpful to understand a little more about what you are trying to fit this code into as a whole 🙂

---

<div class="post-metadata">

**Author:** ![blipson](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/blipson/32/1772_2.png) [@blipson](https://in-thread.sonic-pi.net/u/blipson)\
**Post date:** [May 5, 2021, 7:33am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/3 "2021-05-05T07:33:10Z")

</div>

I think I can totally make this work, thanks.

Yes, I want to pass dynamic parameters to `play`, but because the synths’ parameters can differ, I need to be able to test on those parameter names.

This looks like a pretty simple solution, and I was going to say n00b strikes again except that I don’t see it documented at [the place I usually go to discover features](https://ruby-doc.org/core-2.0.0/Array.html). Googling `to_h` on its own turns up some sources.

---

<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:** [May 5, 2021, 7:38am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/4 "2021-05-05T07:38:59Z")

</div>

> [@blipson](#):
>
> except that I don’t see it documented

`Array#to_h` was introduced in Ruby 2.1 🙂

---

<div class="post-metadata">

**Author:** ![blipson](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/blipson/32/1772_2.png) [@blipson](https://in-thread.sonic-pi.net/u/blipson)\
**Post date:** [May 5, 2021, 7:54am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/5 "2021-05-05T07:54:34Z")

</div>

D’OH!

The system won’t let me write “D’OH” unless I fill the message out to 20 characters.

---

<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:** [May 5, 2021, 7:57am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/6 "2021-05-05T07:57:24Z")

</div>

Haha. I know the feeling! I’ve found that it’s sometimes helpful to try to aim for more recent API docs in the search results by typing things like ‘Ruby 3 array’

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [May 5, 2021, 7:58am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/7 "2021-05-05T07:58:40Z")

</div>

> [@ethancrawford](#):
>
> ```ruby
> x = [[:amp, 0.5], [:release, 0.2]].to_h
> play 60, x
> 
> ```

I might not have quite understood what is trying to be achieved, but if the goal is to work with synth args as values before using them as options to `synth`, `play` or `sample` then it might make sense to work directly with maps/hashes:

```ruby
x = {amp: 0.5, release: 0.2}
play 60, x

```

You can use as many of these as you want:

```ruby
x = {amp: 0.5, release: 0.2}
y = {attack: 0.1}
play 60, x, y

```

The only rule to remember is to ensure that any opt hashes go _before_ standard keyword opts:

```ruby
x = {amp: 0.5, release: 0.2}
y = {attack: 0.1}
play 60, x, y, pan: 1

```

I hope that this helps 🙂

---

<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:** [May 5, 2021, 8:00am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/8 "2021-05-05T08:00:10Z")

</div>

True, I didn’t think of mentioning hashes directly 🙂

---

<div class="post-metadata">

**Author:** ![blipson](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/blipson/32/1772_2.png) [@blipson](https://in-thread.sonic-pi.net/u/blipson)\
**Post date:** [May 5, 2021, 8:24am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/9 "2021-05-05T08:24:41Z")

</div>

Yes, the hash thing looks like the simplest way to do it in my case, thanks.

I’ve never actually used hashes before, just arrays, so I’ll have to study up. I mean, I wonder why the hashes have to go before standard keyword opts, which I’ve verified they do.

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [May 5, 2021, 8:36am UTC](https://in-thread.sonic-pi.net/t/how-to-get-rid-of-quotation-marks-for-splatting-array-of-arguments/5497/10 "2021-05-05T08:36:56Z")

</div>

> [@blipson](#):
>
> I’ve never actually used hashes before, just arrays, so I’ll have to study up.

Hashes are just simple key value pairs. It’s like a telephone directory of names (keys) to phone numbers (values). Unlike a telephone directory in typical programming languages, all the keys of hashes need to be unique - but the values don’t.

> [@blipson](#):
>
> I wonder why the hashes have to go before standard keyword opts

This is just how I implemented it. The keyword opts work using the concept of “all the rest of the function’s arguments” which are then gathered together and turned to a hash and then merged with any other hashes passed as arguments earlier. I actually do quite a lot of work munging the options under the hood to make things simple yet flexible 🙂
