Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _posts/2019-01-17-ruby-mixin-concern.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ irb > MyModule.new.instance_method
클래스의 인스턴스 메서드를 호출하면 ancestors 배열의 앞에서부터 메서드 정의를 찾습니다. 상속 개념과 유사하게, 메서드 정의를 찾지 못하면 다음 조상에게서 찾는 식입니다. 즉 둘 이상의 선조들이 같은 이름의 메서드를 정의하고 있다면 더 가까운 선조에 정의된 메서드를 실행합니다. 참고로 `BasicObject`까지 거슬러 올라갔는데도 메서드를 찾지 못하면 [BasicObject#method_missing](https://ruby-doc.org/core-2.5.0/BasicObject.html#method-i-method_missing)이 실행되는데, 몇몇 루비 gem들은 이를 이용해 이해하기 쉽지 않은 흑마술을 부리기도 하더군요.

```ruby
irb > String.acenstors
irb > String.ancestors
# => [String, Comparable, Object, Kernel, BasicObject]
irb > String.included_modules
# => [Comparable, Kernel]
Expand Down