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 88bc360 commit b1e29a8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Day 7/Break_statement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Break Statement

=begin
Pattern 1:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Pattern 2 by modifying Pattern 1 & using break:
1 2
1 2
1 2
1 2
1 2
=end

# Pattern 1
for r in 1..5
for c in 1..5
print "#{c}"
end
print"\n"
end

# Pattern 2
for r in 1..5
for c in 1..5
print "#{c}"
break if c==2
end
print"\n"
end
17 changes: 17 additions & 0 deletions Day 7/Next_&_Redo_statement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Next & Redo Statement

# Next statement
for i in 0..5
if i < 2
next
end
puts "The value of local variable i = #{i}"
end

# Redo statement
for i in 0..5
if i < 2
puts "The value of local variable i = #{i}"
redo
end
end

0 comments on commit b1e29a8

Please sign in to comment.