Skip to main content

ruby on rails - Get last occurence of nested array -


By querying two sections and applying the following methods:

  .each_with_index. Chunk {| Enum, i | I get this structure:  
  [[False, [[# # Post ID: 1, Title: enum.is_a? (Note)}  

"something", 0]]], [false, [[# # and #; Lit; Post ID: 2, Title: "Something", 1], [# & lt; Post ID: 3, Title: "Something", 2]]], [True, [ID # 1, Title: "Something", 3], [# & lt; Note ID: 77, Title: "Something", 4]]]]

In the scene, I have to know when I am on the last object, in this case the index status 4, I How do i

In this view, you could just do this:

  array .flatten.last  

which looks like this:

  [1] PRI (main)> gt; [[False, [["1"]]], [false, [2]], ["post 3"]], [true, [1], ["note 77"]]]] .flatten Last = & gt; "note 77"  

Thanks for the amendment Cary.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -