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

Scala で empty な Seq に tail すると実行時例外になる

scala> Seq(1, 2, 3).tail
res5: Seq[Int] = List(2, 3)

scala> Seq.empty[Int].tail
java.lang.UnsupportedOperationException: tail of empty list
  at scala.collection.immutable.Nil$.tail(List.scala:433)
  at scala.collection.immutable.Nil$.tail(List.scala:428)
  ... 40 elided

WartRemovertail -> drop(1) に変えろと言われるのはこういうことらしい。

  • こういうメジャーどころのメソッドで実行時例外が起きて
  • 代替手段が drop(1) みたいなブサイクなやつ

だと、なんか萎えるなぁという気持ち。

ちなみに Haskell も標準の List に単純に tail すると Exception を吐く。
関数型界隈で tail といえばこの動作なんだろうか??

Prelude> tail []
*** Exception: Prelude.tail: empty list
Why do not you register as a user and use Qiita more conveniently?
  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
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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