Skip to content

Commit

Permalink
Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
msatmod committed Aug 30, 2022
1 parent b1e29a8 commit dff2e4a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Day 8/Block_with_parameters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Program of Block With Parameters

def call_block
puts "Start of method"
yield("Filly", "2022")
puts"End of method"
end

call_block do
|str, num| puts "Inside the block: " +str+" "+ num.to_s
end
11 changes: 11 additions & 0 deletions Day 8/Block_without_parameters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Program of Block Without Parameters

def call_block
puts "Start of method"
yield
puts"End of method"
end

call_block do
puts "Inside the block"
end
10 changes: 10 additions & 0 deletions Day 8/Passing_a_block_to_a_method.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Program of Passing a Block to a Method

def filly(&b)
#yield
3.times do b.call end
end

filly do
puts "THE MEGA!"
end

0 comments on commit dff2e4a

Please sign in to comment.