Skip to content

Instantly share code, notes, and snippets.

@simandebvu
Created June 2, 2020 20:28
Show Gist options
  • Save simandebvu/02b6c83e755d34e933c4ee0cbccc1c03 to your computer and use it in GitHub Desktop.
Save simandebvu/02b6c83e755d34e933c4ee0cbccc1c03 to your computer and use it in GitHub Desktop.

Revisions

  1. simandebvu created this gist Jun 2, 2020.
    14 changes: 14 additions & 0 deletions procs.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    peoples_ages = [25, 28, 36, 15, 17]

    # Definition
    ## First method
    my_proc = Proc.new {|n| n>30}
    ## Second method
    my_proc_two = proc {|n| n>12 }

    ## They can now be reused by calling
    e = peoples_ages.select(&my_proc)
    d = peoples_ages.select(&my_proc_two)

    ## You can call them using
    &my_proc.call()