SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
self
@ 80 ruby
• :
• SNS: @yalab
• :
• : ( )
• ruby : since 1.6
• : ruby trunk mjit merge
1 name = "Yoshida" #
2 name.size #
1 name = "Yoshida" #
2 name.size #
1 name = "Yoshida" #
2 name.size #
1 public_methods
• )
• )
1 self.public_methods
"self"
Y^Y^Y^Y^Y^Y
self
1 p self #=> main
2
3 class A
4 p self #=> A
5 def method
6 p self #=> #<A:0x007fdf1002cf28>
7 end
8
9 def self.classmethod
10 p self #=> A
11 end
12 end
13
14 A.module_eval do
15 p self #=> A
16 end
1 class Animal
2 def type
3 :animal
4 end
5 end
6
7 class Human < Animal
8 def initialize(name)
9 @name = name
10 end
11
12 def name
13 "#{@name}(#{type})" #<- type
14 end
15 end
1 class User < ApplicationRecord
2 validates :name, presence: true
3 end
1 class User < ApplicationRecord
2 self.validates(:name, {presence: true})
3 end
1 class User < ApplicationRecord
2 validates :name, presence: true
3 end
)private
self
self
1 p self.class #=>
2 p self.class.ancestors #=>
3 p self.instance_variables #=>
4 p self.methods #=>
5 p self.methods.grep /write/ #=>
6 p self.method(:tap).source_location #=>
Object,Class,Module
https://docs.ruby-lang.org/ja/2.5.0/class/Object.html
https://docs.ruby-lang.org/ja/2.5.0/class/Class.html
https://docs.ruby-lang.org/ja/2.5.0/class/Module.html
self ruby
self
self
Selfを考える

Weitere ähnliche Inhalte

Ähnlich wie Selfを考える

Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v RubyJano Suchal
 
RubyistのためのObjective-C入門
RubyistのためのObjective-C入門RubyistのためのObjective-C入門
RubyistのためのObjective-C入門S Akai
 
Object.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examplesObject.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examplesRobert Lujo
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma IntroduçãoÍgor Bonadio
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 

Ähnlich wie Selfを考える (7)

Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v Ruby
 
RubyistのためのObjective-C入門
RubyistのためのObjective-C入門RubyistのためのObjective-C入門
RubyistのためのObjective-C入門
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
Object.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examplesObject.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examples
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 

Mehr von よしだ あつし

serviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おうserviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おうよしだ あつし
 
ruby で書く 脆弱なコード
ruby で書く 脆弱なコードruby で書く 脆弱なコード
ruby で書く 脆弱なコードよしだ あつし
 
Railsにコントリビュートしてきました
RailsにコントリビュートしてきましたRailsにコントリビュートしてきました
Railsにコントリビュートしてきましたよしだ あつし
 
低レイヤから見たrubyプログラミング
低レイヤから見たrubyプログラミング低レイヤから見たrubyプログラミング
低レイヤから見たrubyプログラミングよしだ あつし
 
まじょのおしごとの裏側
まじょのおしごとの裏側まじょのおしごとの裏側
まじょのおしごとの裏側よしだ あつし
 
僕が勉強をする モチベーションと勉強法
僕が勉強をする モチベーションと勉強法僕が勉強をする モチベーションと勉強法
僕が勉強をする モチベーションと勉強法よしだ あつし
 
よい名前を付けましょう リーダブルなんたらとか
よい名前を付けましょう   リーダブルなんたらとかよい名前を付けましょう   リーダブルなんたらとか
よい名前を付けましょう リーダブルなんたらとかよしだ あつし
 
私はいかにしてpull request を行ったか - あるいは social development について
私はいかにしてpull request を行ったか - あるいは social development について私はいかにしてpull request を行ったか - あるいは social development について
私はいかにしてpull request を行ったか - あるいは social development についてよしだ あつし
 
15分でできるSQLインジェクション
15分でできるSQLインジェクション15分でできるSQLインジェクション
15分でできるSQLインジェクションよしだ あつし
 
Next GAE Heroku を使って 3分でRailsアプリをリリース
Next GAE Heroku を使って 3分でRailsアプリをリリースNext GAE Heroku を使って 3分でRailsアプリをリリース
Next GAE Heroku を使って 3分でRailsアプリをリリースよしだ あつし
 
デバッガでデバッグしない
デバッガでデバッグしないデバッガでデバッグしない
デバッガでデバッグしないよしだ あつし
 
Twitterでネットストーカーをしよう
TwitterでネットストーカーをしようTwitterでネットストーカーをしよう
Twitterでネットストーカーをしようよしだ あつし
 

Mehr von よしだ あつし (20)

serviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おうserviceクラスをやめようサブクラスを使おう
serviceクラスをやめようサブクラスを使おう
 
ruby で書く 脆弱なコード
ruby で書く 脆弱なコードruby で書く 脆弱なコード
ruby で書く 脆弱なコード
 
CTOのおしごと
CTOのおしごとCTOのおしごと
CTOのおしごと
 
Railsにコントリビュートしてきました
RailsにコントリビュートしてきましたRailsにコントリビュートしてきました
Railsにコントリビュートしてきました
 
Rubyコードの最適化
Rubyコードの最適化Rubyコードの最適化
Rubyコードの最適化
 
低レイヤから見たrubyプログラミング
低レイヤから見たrubyプログラミング低レイヤから見たrubyプログラミング
低レイヤから見たrubyプログラミング
 
まじょのおしごとの裏側
まじょのおしごとの裏側まじょのおしごとの裏側
まじょのおしごとの裏側
 
僕が勉強をする モチベーションと勉強法
僕が勉強をする モチベーションと勉強法僕が勉強をする モチベーションと勉強法
僕が勉強をする モチベーションと勉強法
 
Dockerプレゼン
DockerプレゼンDockerプレゼン
Dockerプレゼン
 
Vue.js ハンズオン資料
Vue.js ハンズオン資料Vue.js ハンズオン資料
Vue.js ハンズオン資料
 
よい名前を付けましょう リーダブルなんたらとか
よい名前を付けましょう   リーダブルなんたらとかよい名前を付けましょう   リーダブルなんたらとか
よい名前を付けましょう リーダブルなんたらとか
 
Gitの使い方あれこれ
Gitの使い方あれこれGitの使い方あれこれ
Gitの使い方あれこれ
 
私はいかにしてpull request を行ったか - あるいは social development について
私はいかにしてpull request を行ったか - あるいは social development について私はいかにしてpull request を行ったか - あるいは social development について
私はいかにしてpull request を行ったか - あるいは social development について
 
15分でできるSQLインジェクション
15分でできるSQLインジェクション15分でできるSQLインジェクション
15分でできるSQLインジェクション
 
Next GAE Heroku を使って 3分でRailsアプリをリリース
Next GAE Heroku を使って 3分でRailsアプリをリリースNext GAE Heroku を使って 3分でRailsアプリをリリース
Next GAE Heroku を使って 3分でRailsアプリをリリース
 
テスト駆動開発入門
テスト駆動開発入門テスト駆動開発入門
テスト駆動開発入門
 
Railsの今昔
Railsの今昔Railsの今昔
Railsの今昔
 
デバッガでデバッグしない
デバッガでデバッグしないデバッガでデバッグしない
デバッガでデバッグしない
 
Rails3使用雑感
Rails3使用雑感Rails3使用雑感
Rails3使用雑感
 
Twitterでネットストーカーをしよう
TwitterでネットストーカーをしようTwitterでネットストーカーをしよう
Twitterでネットストーカーをしよう
 

Kürzlich hochgeladen

Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 

Kürzlich hochgeladen (20)

Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 

Selfを考える