LoginSignup
3
3

More than 5 years have passed since last update.

Ruby メモ

Last updated at Posted at 2016-12-16

はじめに

下書きがいっぱいになった&公開したら良いじゃんというのをうけ公開する
メモなので新しいことがあると更新していく

Rubyの命名規則

ここを参考にしてる
http://qiita.com/takahashim/items/ccfd489c9b26f15b7193

Rubyにおけるドット記法,二重コロン記法

違い
レシーバ::メソッド → 定数呼び出しが可能
レシーバ.メソッド → 定数呼び出しはデフォルトでは不可能

ドット記法でもアクセスメソッドを定義することで呼び出しは可能になる
http://www.rubylife.jp/ini/class/index6.html

クラスメソッドとインスタンスメソッド

クラスに生やすかインスタンスに生やすか
クラスメソッドはself.メソッドで宣言
http://qiita.com/tbpgr/items/56eb65c0ea5882abbb07

Rubyでのクラス変数、インスタンス変数、クラスインスタンス変数の違いについて

モジュールとクラス

http://qiita.com/fukumone/items/2dd4d2d1ce6ed05928de
http://qiita.com/ionis_h/items/5f26248ea4e154cce424

クラスのto_json

オプションの引数(*a)は必要
http://shokai.org/blog/archives/6124

配列のコピーについて

後半に記述
http://qiita.com/sue738/items/92228f0ae0518bf0a693

ボッチ演算子

&: でオブジェクトに生えたものにアクセス

hashのキー

シンボルと文字列で区別してる
http://qiita.com/QUANON/items/169c73425a6bc50dee51

injectとeach_with_object

エラー処理

begin - rescueとraise
http://qiita.com/murata0705/items/6ae346bd04197fb2e36a

yieldについて

引数で渡された処理や関数を実行
http://qiita.com/merrill/items/0a77df7f61d0d6b8e875

自己代入などについて

|| ||=など
https://docs.ruby-lang.org/ja/latest/doc/spec=2foperator.html

オープンクラス refinements

http://blog.fenrir-inc.com/jp/2014/07/refine.html
http://qiita.com/yustoris/items/77fd309178dcdd13b5cd

case

caseはrubyでのswitch
case when elseでかける
Cと違ってwhenを並べても処理が下に流れていかない

オープンクラス

http://www.ruby.or.jp/ja/tech/development/ruby/tutorial/090_class_extension.html
railsで使う時
http://qiita.com/k-yamada@github/items/707687449da75da4c78c

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