Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 코틀린
- 주차장 시스템
- 사용중인포트검색
- 이것이 자바다
- Ruby on Rails
- 쿠버네티스
- after_update
- 설치
- 오랜지파이
- Kotlin
- RUBY
- Orange Pi 3B
- install
- MySQL
- Migrate
- 우분투 24
- ubuntu
- docket
- after_save
- Java
- Time.znoe.now
- 도커
- Rails
- Visual Studio Code
- with_indifferent_access
- change_column
- change_column_null
- docker
- 우분투
- mac
Archives
- Today
- Total
중고 신입이 개발해보기..
ruby block 본문
ruby코드를 보는중..
yield if block_given?
라는것이 있다..
https://smartbase.tistory.com/54 참고
Ruby 처음 배우기 : Block & Yield
Blocks 블록은 클로저 혹은 익명함수와 비슷합니다. 즉 이름 없는 메서드를 생성하는 방법이라고 할 수 있으며, do...end 혹은 {} 로 정의합니다. 블록은 처리를 하나의 단위로 묶은 것으로, 메서드
smartbase.tistory.com
def block_given_sample
puts "before yield"
yield if block_given?
puts "after yield"
end
메서드가 있다..
block_given_sample
실행하면...
before yield
after yield
만 나오지만
block_given_sample do
puts "block"
end
로 실행하면..
yield if block_given? 부분에서 puts "block" 이 실행된다.
before yield
block
after yield
'Back-End > Ruby On Rails' 카테고리의 다른 글
after_update와 after_save의 차이는? (0) | 2024.01.23 |
---|---|
Rails로 서버 만들기 (0) | 2023.04.25 |
Rails 6 Multiple database (0) | 2022.11.29 |
[Ruby on Rails : Heroku] 무료서버만들기 (0) | 2022.03.23 |
레일즈 디비 설정 변경 (0) | 2022.03.17 |
Comments