I have some code that adds to a session array like so:
if policy_session[:modalities] #array exists just add new value to it
policy_session[:modalities] << [params[:modality], policy_session[:mode_list]]
else #the array does't exist yet, so create and add first one.
policy_session[:modalities] = [params[:modality], policy_session[:mode_list]]
but this produces horrible formatting on my :modalities array. It looks like this:
>> policy_session[:modalities]
>># [["var_1"], "1",[["var_2"], ["2"]], [["var_3"], ["1"]]]
Which is a total pain to try and iterate over later in my program.
I have tried a bunch of different things, but haven't come up with anything that really looks better then this.
How do I create and then add to the array such that my output will be readable? And all formatted the same!
I would like something like this:
>>policy_session[:modalities]
>># [["var_1", "1"], ["var_2", "2"], ["var_3", "1"]]