以下の内容はhttps://at-grandpa.hatenablog.jp/entry/2017/12/24/025613より取得しました。


Crystalのsyntax紹介 "abstract class"

この記事は、 Crystal Advent Calendar 2017 の22日目を埋める記事です。

crystalには、痒いところに手が届く構文があります。

今回は abstract class を紹介します。

abstract class

詳細はDocsにあります。

Virtual and abstract types · GitBook

crystalでは、他の言語でお馴染みの abstract class を定義できます。

abstract class A
  abstract def abstract_method
end

a = A.new # => Error: can't instantiate abstract class A

class B < A
  def abstract_method
    1
  end
end

b = B.new # => #<B:0x1064d2ff0>

これ以上の説明はありませんが、使ってみたい方はぜひどうぞ。




以上の内容はhttps://at-grandpa.hatenablog.jp/entry/2017/12/24/025613より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14