10
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

複数の Range を結合する

Last updated at Posted at 2015-09-18

複数の範囲をくっつけて使いたいシチュエーションがあって、いい書き方がないかなぁ、と探してみた。

単純にやると、配列にして結合するのが手っ取り早いけど、いまいち見づらい。

(0..48).to_a + (50..255).to_a

調べると、Stack Overflow に素晴らしい方法がのってました。

[*0..48, *50..255]

これは、見やすいですねー

10
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?