Sha256: bafc343b8ed5bda3e6924efad95f3cc9e696a82622b8c6f4da056b80b0cc5d93

Contents?: true

Size: 882 Bytes

Versions: 3

Compression:

Stored size: 882 Bytes

Contents

require "iolite"


#######################################
# Using block
#######################################

p (1..5).map { |it| it + 3 }
# => [4, 5, 6, 7, 8]

p (1..5).inject { |memo, item| memo + item }
# => 15

p ["homu", "mami", "an"].inject(0) { |memo, item| memo + item.length }
# => 10

p [{name: :homu}, {name: :mami}].map { |it| it[:name] }
# => [:homu, :mami]

p [:homu, :mami, :mado].select { |it| it =~ /^m/ }
# => [:mami, :mado]


#######################################
# Using iolite
#######################################

# using arg1, arg2...
include Iolite::Placeholders

p (1..5).map &arg1 + 3
# => [4, 5, 6, 7, 8]

p (1..5).inject &arg1 + arg2
# => 15

p ["homu", "mami", "an"].inject 0, &arg1 + arg2.length
# => 10

p [{name: :homu}, {name: :mami}].map &arg1[:name]
# => [:homu, :mami]

p [:homu, :mami, :mado].select &arg1 =~ /^m/
# => [:mami, :mado]


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iolite-0.0.3 example/simple.rb
iolite-0.0.2 example/simple.rb
iolite-0.0.1 example/simple.rb