Skip to content

Sat public review Command A (Zal 3)#16

Open
samsonovkirill wants to merge 4 commits intorubyroidlabs:sat-public-reviewfrom
samsonovkirill:sat-public-review
Open

Sat public review Command A (Zal 3)#16
samsonovkirill wants to merge 4 commits intorubyroidlabs:sat-public-reviewfrom
samsonovkirill:sat-public-review

Conversation

@samsonovkirill
Copy link
Copy Markdown
Contributor

@samsonovkirill samsonovkirill commented Apr 3, 2021

No description provided.

sets = towers.map do |tower|
result = []
column = Array.new(@tower_size, " ")
column.each_index do |i|
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each_with_object method might be used in cases you want to fill new Array/Hash by iterating some data,

result[i] = tower[i]
else
result[i] = column[i]
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice practice to use oneliners like result[i] = tower[i] ? tower[i] : column[i]

@@ -0,0 +1,6 @@
require_relative './towers_of_hanoi'

if __FILE__ == $PROGRAM_NAME
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I remember we agreed that this checkup would be excessive

end
@towers = @towers.map{|column| column.reject{|x| x == " "} }
@sets
self.towers = towers.map{|column| column.reject{|x| x == " "} }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of a real project with larger classes and significant amount of variables and methods self.towers = towers might look confusing. In future try to find more clear way of assignment )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants