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

Crystal 入門

More than 3 years have passed since last update.

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

vim

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

仕様その他

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

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

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

a = 1
a = "string"

これは通る。

オーバーロード

http://crystal-lang.org/docs/syntax_and_semantics/overloading.html

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 にも欲しい……

名前付き引数

http://crystal-lang.org/docs/syntax_and_semantics/default_and_named_arguments.html

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

Abstract types

http://crystal-lang.org/docs/syntax_and_semantics/virtual_and_abstract_types.html

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

Macro

http://crystal-lang.org/docs/syntax_and_semantics/macros.html

マクロあるの……

触ってみた

rosylilly
Ruby と Javascript を少々
http://aduca.org
cookpad
料理をするユーザーさんをテクノロジの力で笑顔にする
http://cookpad.com/
Why not register and get more from Qiita?
  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
No 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
ユーザーは見つかりませんでした