< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous artilce (have the same parent)
N :the next artilce (have the same parent)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
Am 11.07.2013 09:34, schrieb stefan heinrich:
> my code to read out the tablewidget and create the array.
>
> array = Array.new
>
> for i in 0..rowCount - 1
> tmp = Array.new
> tmp << @tableWidget.item(i, 1).text.to_a
> tmp << @tableWidget.item(i, 0).text.to_a
> tmp = tmp[0] + tmp[1]
>
> array << tmp
> end
>
> array.group_by {|s,i| s}
> array= array.group_by {|s,i| s}.each {|k,v| v.map! {|s,i| i}}
>
> The 2d array looks like this after grouping
>
> {"I OFF"=>["a8", "1e"], "E OFF"=>["98", "a0"], "Emphasized ON"=>["db"],
> "I ON"=>["99"]}
>
> It seems like after using grouping by it is not an array anymore.
Yes indeed, as mentioned several times in the previous posts, we are
talking about a **Hash** of key-value pairs (where the values in this
case are arrays). And I already demonstrated in my examples how you
can access the stored arrays separately.
A reminder:
data = {"I OFF"=>["a8", "1e"], "E OFF"=>["98", "a0"], "Emphasized
ON"=>["db"], "I ON"=>["99"]}
p data['I OFF'] # => ["a8", "1e"]
Also, I would like to repeat myself:
> I suggest you also look into the docs for the Hash class and
> make heavy use of irb.
And: Try to figure out what happens in the code examples that
people provide here.
Regards,
Marcus
--
<https://github.com/stomar/>