0
0

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.

[メモ] rubyについて

Last updated at Posted at 2019-09-14

メソッドについて

代入関数とは

サンプル

class Hoge
 def current_user=(user)
  @current_user = user
 end
end

hoge = Hoge.new
hoge.current_user = 'HogeHoge'

普通のメソッド

class Hoge
  def current_user(user)
    @current_user = user
  end
end

hoge = Hoge.new
hoge.current_user('HogeHoge')

mapの使い方

配列でもいける

Array.map{|obj|
 #  計算式..etc
}

hashでもいける

Hash.map{|obj|
 #  計算式..etc
}

省略した書き方でもいける

Hash.map(&:メソッド名)
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?