How can I break a long ruby hash into multi-lines? -
i have hash:
arr={ [0,1]=>[0,0,1,1], [0,2]=>[0,1,0,1], [0,3]=>[0,1,1,0], [1,2]=>[1,0,0,1], [1,3] =>[1,0,1,0], [2,3] => [1,1,0,0] }
and want split on 2 lines quite long, @ 121 characters. i'm not sticker line length guide line 80 , longer prefer
so tried
arr={ [0,1] => [0,0,1,1], [0,2] => [0,1,0,1], [0,3] => [0,1,1,0] } arr.merge({[1,2] => [1,0,0,1], [1,3] => [1,0,1,0], [2,3] => [1,1,0,0]})
but tests fail with errors like
undefined method `[]' nil:nilclass
how can better break up? 1 option line continuation \
didn't particularly neat.
arr={ [0,1]=>[0,0,1,1], [0,2]=>[0,1,0,1], [0,3]=>[0,1,1,0], \ [1,2]=>[1,0,0,1], [1,3] =>[1,0,1,0], [2,3] => [1,1,0,0] }
although guess do
arr={ [0,1]=>[0,0,1,1], [0,2]=>[0,1,0,1], [0,3]=>[0,1,1,0], \ [1,2]=>[1,0,0,1], [1,3] =>[1,0,1,0], [2,3] => [1,1,0,0] }
but looks w whitespace maintenance smell indentation.
are there neater options?
arr = { [0,1] => [0,0,1,1], [0,2] => [0,1,0,1], [0,3] => [0,1,1,0], [1,2] => [1,0,0,1], [1,3] => [1,0,1,0], [2,3] => [1,1,0,0] }
Comments
Post a Comment