Help us understand the problem. What is going on with this article?

# PPAP with Ruby

More than 3 years have passed since last update.

# PPAP with Ruby

## ループ

```PPAP = ["\u2712\ufe0f", "\u{1f34d}\ufe0f", "\u{1f34e}\ufe0f", "\u2712\ufe0f"]

ppap = []

until ppap.last(4) == PPAP do
ppap << PPAP.sample.tap(&method(:print))
end

puts "ペンパイナッポーアッポーペン"
```

## 再帰

```PPAP = ["\u2712\ufe0f", "\u{1f34d}\ufe0f", "\u{1f34e}\ufe0f", "\u2712\ufe0f"]

def pikotaro(ppap=[])
return "ペンパイナッポーアッポーペン" if ppap == PPAP
pikotaro(ppap.last(3) << PPAP.sample.tap(&method(:print)))
end

puts pikotaro
```

## 遅延評価

```PPAP = ["\u2712\ufe0f", "\u{1f34d}\ufe0f", "\u{1f34e}\ufe0f", "\u2712\ufe0f"]

loop
.lazy
.map {PPAP.sample.tap(&method(:print))}
.each_cons(4) {|ppap| break puts "ペンパイナッポーアッポーペン" if ppap == PPAP}
```

# 実行結果

```\$ ruby ppap.rb
🍎️✒️✒️🍎️🍎️✒️🍍️✒️🍍️✒️🍎️✒️✒️🍎️🍍️🍍️✒️🍎️✒️✒️🍎️✒️🍎️✒️✒️🍎️🍎️🍍️✒️🍎️✒️✒️✒️✒️✒️🍎️✒️✒️🍎️🍍️🍍️🍎️✒️🍍️🍍️✒️✒️🍍️✒️✒️✒️✒️✒️✒️🍎️🍍️🍎️✒️✒️✒️✒️🍎️🍍️🍎️🍎️🍎️🍍️🍍️🍎️✒️✒️🍍️✒️🍎️🍎️✒️✒️🍎️✒️🍍️🍍️🍎️🍍️🍎️🍍️✒️🍎️🍍️🍎️✒️🍎️🍍️✒️✒️🍍️🍍️✒️✒️✒️✒️🍎️✒️🍍️✒️✒️🍎️✒️🍍️🍍️✒️🍍️✒️🍍️✒️🍍️🍎️🍍️✒️✒️✒️🍎️✒️✒️✒️✒️✒️✒️🍍️🍍️✒️🍎️🍎️✒️✒️🍎️✒️🍍️✒️🍍️🍎️✒️ペンパイナッポーアッポーペン
```

# 参考

#PrayForKyoani
https://foooomio.net/
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away