LoginSignup
73
73

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