LoginSignup
1
1

More than 5 years have passed since last update.

Ninety-Nine Scala Problems奮闘記1

Posted at

P1: Find the last element of a list.

Unit???

どうにかIntelliJを設定,プロジェクトを作成して,mainメソッドを作ったら出てきた.
なんだこれ,と思ったら戻り値を返さないよ,って意味なんですね….

class? object?

入門ページをいくつか見ていると,(Javaでお馴染みの)classを定義しているページと,classの代わりに「object」を定義しているページがある….ので調べたら

  • classはnewキーワードでインスタンス化できる。変数、定数、メソッドを持つ。
  • objectはシングルトンオブジェクト。Javaでいうstaticで、インスタンス化できないこと以外はclassと同様に使用できる。

とのことでした.

再帰プログラミング

ぜんぜんわかりませんでした.再帰っていうより,Scalaのパターンマッチングがわかってないのかなぁ….

参考
S-99: Ninety-Nine Scala Problems
基本的なパターンマッチとScalaで重要な“関数”

1
1
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
1
1