-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New Concept & Exercise]: Iteration #627
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this might be introducing too much. It's not just iteration, it's also introducing:
present?
,empty?
,any?
,all?
,none?
,one?
count
sort_by
I would have expected this exercise to be about each
and times
and possibly map
and reduce
.
…k and expanded some content
concepts/iteration/about.md
Outdated
Both the `Array` and `Range` classes in Crystal include the [`Enumerable`][enumerable] module, which provides a number of methods for iterating over the elements. | ||
Meanwhile, the `String` class has its own set of methods for iterating over the characters. | ||
|
||
Crystal also doesnt have any any for statement like other languages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crystal also doesnt have any any for statement like other languages. | |
Crystal also doesn't have any for statement like other languages. |
concepts/iteration/about.md
Outdated
|
||
The most common way to iterate over a collection is to use the [`each`][each] method, which yields each element in the collection to a block. | ||
This can be done easily with a `Range`. | ||
Say you would want to loop between 1 and 3, you can use the `each` method to iterate over the range. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Say you would want to loop between 1 and 3, you can use the `each` method to iterate over the range. | |
Say you want to loop between 1 and 3, you can use the `each` method to iterate over the range. |
concepts/iteration/about.md
Outdated
# 3 | ||
``` | ||
|
||
Even simplier if you just want to iterate n numbers of times you can use the [`times`][times] method, which exists on the `Int` class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even simplier if you just want to iterate n numbers of times you can use the [`times`][times] method, which exists on the `Int` class. | |
Even simpler, if you just want to iterate a number of times you can use the [`times`][times] method, which exists on the `Int` class. |
concepts/iteration/about.md
Outdated
|
||
## Iterating over a `String` | ||
|
||
A `String` is a sequence of characters, and doesnt belong to the `Enumerable` module, which means it has its own set of methods for iterating over the characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A `String` is a sequence of characters, and doesnt belong to the `Enumerable` module, which means it has its own set of methods for iterating over the characters. | |
A `String` is a sequence of characters and doesn't belong to the `Enumerable` module, which means it has its own set of methods for iterating over the characters. |
concepts/iteration/about.md
Outdated
# o | ||
``` | ||
|
||
Another way of iterating over a `String` is to use the [`each_line`][each_line] method, this method is mostly used when reading a file line by line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way of iterating over a `String` is to use the [`each_line`][each_line] method, this method is mostly used when reading a file line by line. | |
Another way of iterating over a `String` is to use the [`each_line`][each_line] method. | |
This method is mostly used when reading a file line by line. |
SpellboundSteel.calculate_power_level(deck).should eq(35) | ||
end | ||
|
||
it "should return 65 if the deck has a Rogue and Ice Storm " do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "should return 65 if the deck has a Rogue and Ice Storm " do | |
it "should return 65 if the deck has a Rogue and an Ice Storm " do |
SpellboundSteel.decode_characters("").should eq("") | ||
end | ||
|
||
it "should return warrior if the inut is wbalrrrlimoqr" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "should return warrior if the inut is wbalrrrlimoqr" do | |
it "should return warrior if the input is wbalrrrlimoqr" do |
SpellboundSteel.decode_characters("wbalrrrlimoqr").should eq("warrior") | ||
end | ||
|
||
it "should return mage if the inut is mlabgle" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "should return mage if the inut is mlabgle" do | |
it "should return mage if the input is mlabgle" do |
SpellboundSteel.decode_characters("mlabgle").should eq("mage") | ||
end | ||
|
||
it "should return rogue if the inut is rloguqgle" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "should return rogue if the inut is rloguqgle" do | |
it "should return rogue if the input is rloggquge" do |
def self.sort_cards_by_power_level(characters) | ||
raise "Please implement the SpellboundSteel.sort_cards_by_power_level method" | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def self.sort_cards_by_power_level(characters) | |
raise "Please implement the SpellboundSteel.sort_cards_by_power_level method" | |
end |
No description provided.