# Little hacky thing for passing variables between buffers

**URL:** <https://in-thread.sonic-pi.net/t/little-hacky-thing-for-passing-variables-between-buffers/4748>\
**Category:** Creations & Ideas\
**Created:** [December 6, 2020, 12:40am UTC](https://in-thread.sonic-pi.net/t/little-hacky-thing-for-passing-variables-between-buffers/4748 "2020-12-06T00:40:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![theibbster](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@theibbster](https://in-thread.sonic-pi.net/u/theibbster)\
**Post date:** [December 6, 2020, 12:40am UTC](https://in-thread.sonic-pi.net/t/little-hacky-thing-for-passing-variables-between-buffers/4748/1 "2020-12-06T00:40:17Z")

</div>

Today in my jam session I was wanting to define variables for sample paths in one buffer and then use them in another one. But, I didn’t really want to set & get them, I wanted to just be able to put their names down.

So I did it like this:

```ruby
samps = {
  bass_loop: '~\samplepath',
  shaker_loop: '~\samplepath' ,
  loud_city: '~\samplepath',
}.each do |k,v|
  define k.to_sym do
    return v
  end
end

```

I had quite a few samples I was using in this session, so I didn’t wanna `define` them by hand.

I imagine there’s probably a simpler solution I completely missed 😃

---

<div class="post-metadata">

**Author:** ![uriel](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/uriel/32/2146_2.png) [@uriel](https://in-thread.sonic-pi.net/u/uriel)\
**Post date:** [November 9, 2021, 5:01am UTC](https://in-thread.sonic-pi.net/t/little-hacky-thing-for-passing-variables-between-buffers/4748/2 "2021-11-09T05:01:21Z")

</div>

Hi 🙂  
may i ask why you dont want to use set/get ?  
your solution looks great, i will test it soon, thx

uriel
