# Correctly splatting for String Tuples

**URL:** <https://discourse.julialang.org/t/correctly-splatting-for-string-tuples/78655>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 29, 2022, 7:17am UTC](https://discourse.julialang.org/t/correctly-splatting-for-string-tuples/78655 "2022-03-29T07:17:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwhisena](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mwhisena](https://discourse.julialang.org/u/mwhisena)\
**Post date:** [March 29, 2022, 7:17am UTC](https://discourse.julialang.org/t/correctly-splatting-for-string-tuples/78655/1 "2022-03-29T07:17:04Z")

</div>

I’m attempting to splat two string tuples (n and m dims) so that they create a n by m array with the combinations of every element together. So if I have

```julia
data=
       (
           ("1.20e3", "1.08e3", "0.96e3"),
           ("3.0e5", "2.7e5")
       )

```

Then if I apply

```julia
vec(collect.(Base.product(data...)))

```

I can get

```julia
6-element Vector{Vector{String}}:
 ["1.20e3", "3.0e5"]
 ["1.08e3", "3.0e5"]
 ["0.96e3", "3.0e5"]
 ["1.20e3", "2.7e5"]
 ["1.08e3", "2.7e5"]
 ["0.96e3", "2.7e5"]

```

This code works for any size n and m as long as they are both greater than 1. But if I have

```julia
data=
       (
           ("1.20e3", "1.08e3", "0.96e3"),
           ("3.0e5")
       )

```

Then I get

```julia
15-element Vector{Vector{Any}}:
 ["1.20e3", '3']
 ["1.08e3", '3']
 ["0.96e3", '3']
 ["1.20e3", '.']
 ["1.08e3", '.']
 ["0.96e3", '.']
 ["1.20e3", '0']
 ["1.08e3", '0']
 ["0.96e3", '0']
 ["1.20e3", 'e']
 ["1.08e3", 'e']
 ["0.96e3", 'e']
 ["1.20e3", '5']
 ["1.08e3", '5']
 ["0.96e3", '5']

```

when obviously I would like it to be

```julia
3-element Vector{Vector{String}}:
 ["1.20e3", "3.0e5"]
 ["1.08e3", "3.0e5"]
 ["0.96e3", "3.0e5"]

```

My understanding is that when I apply the splatting operator, it expands the single element tuple as a iterator of characters rather than an iterator of strings in a tuple.

So would anyone know how I could get the behavior that I outlined? I am working on a code that interfaces with OpenFOAM so the strings are properties of fluid variables that I need to replace in OpenFOAM text dictionaries. Thank you if you spend time on my question! Have a good day.

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [March 29, 2022, 7:19am UTC](https://discourse.julialang.org/t/correctly-splatting-for-string-tuples/78655/2 "2022-03-29T07:19:46Z")

</div>

Hi, In your second example, `("3.0e5")` is not parsed as a tuple but as a string. You’d need a comma in there `("3.0e5", )`

---

<div class="post-metadata">

**Author:** ![mwhisena](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mwhisena](https://discourse.julialang.org/u/mwhisena)\
**Post date:** [March 29, 2022, 7:34am UTC](https://discourse.julialang.org/t/correctly-splatting-for-string-tuples/78655/3 "2022-03-29T07:34:59Z")

</div>

Yes that was it, thank you! I see now that’s directly in the documentation of Julia tuples. Sorry for the trouble.

---

<div class="post-metadata">

**Author:** ![korsbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/korsbo/32/15942_2.png) [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Post date:** [March 29, 2022, 8:27am UTC](https://discourse.julialang.org/t/correctly-splatting-for-string-tuples/78655/4 "2022-03-29T08:27:24Z")

</div>

No problems at all, sometimes we get blind about our own bugs and can spend way too long on them when a pair of fresh eyes might catch the problem in seconds.
