73
73

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.

Crystal 入門

Last updated at Posted at 2015-06-07

Crystal というのが Ruby 似の言語らしいので試してみる。

vim

https://github.com/rhysd/vim-crystal を入れる。

仕様その他

http://crystal-lang.org/docs/ に公式のドキュメントがあるので読んでいく。

大体 Ruby と同じ文法だと思って差し支えないようだけれど、いくつか差異があるので気をつけながら読む。

ぐっと来たとこ書いていく

a = 1
a = "string"

これは通る。

オーバーロード

class Pigeon
  getter name

  def initialize(@name)
  end

  def appeal
    puts("My name is #{@name}.")
  end

  def appeal(n : Int)
    n.times do
      appeal
    end
  end
end

hato = Pigeon.new("rosylilly")

hato.appeal
hato.appeal(5)
hato.appeal(5.5) # => no overload matches

Ruby にも欲しい……

名前付き引数

そう、こう、こういうのでいいんだよ。

Abstract types

さっきから欲しいものバンバンでてきてすごい

Macro

マクロあるの……

触ってみた

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?