sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [Code] Ruby snippets

    Scheduled Pinned Locked Moved Developers' Forum
    1 Posts 1 Posters 1.5k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      Just making a thread to post small little snippets I find useful.

      Enumerator#inject method is one method I've discovered very late, but I'm finding it very useful:

      ` a=[-5,2,5,1,4,8,9,6,2,5,5,1,4]
      => [-5, 2, 5, 1, 4, 8, 9, 6, 2, 5, 5, 1, 4]

      min = a.inject(0) { |m,i| ( i < m ) ? i : m }
      => -5

      max = a.inject(0) { |m,i| ( i > m ) ? i : m }
      => 9

      total = a.inject(0) { |m,i| i + m }
      => 47`

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement