-
-
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]: Array #515
[New Concept]: Array #515
Conversation
concepts/array/about.md
Outdated
|
||
## Empty Arrays | ||
|
||
When creating an empty array, can the compiler not infer which type the array is built of. |
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.
When creating an empty array, can the compiler not infer which type the array is built of. | |
When creating an empty array, the compiler cannot infer the type of the array. |
concepts/array/about.md
Outdated
This can be done by either specifying the type of the array or by using the `of` keyword. | ||
Or by using the array initializer syntax, which is: `Array(T).new`. |
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.
This can be done by either specifying the type of the array or by using the `of` keyword. | |
Or by using the array initializer syntax, which is: `Array(T).new`. | |
This can be done by specifying the type of the array, by using the `of` keyword, or by using the array initializer syntax, which is: `Array(T).new`. |
concepts/array/about.md
Outdated
|
||
## Accessing Elements | ||
|
||
As with `String`, can you access elements in an array by using the [`[]` (index) operator][index] and giving it the index of the element you want to access. |
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.
As with `String`, can you access elements in an array by using the [`[]` (index) operator][index] and giving it the index of the element you want to access. | |
As with `String`, you can access elements in an array by using the [`[]` (index) operator][index] and giving it the index of the element you want to access. |
concepts/array/about.md
Outdated
|
||
## Deleting element from an array | ||
|
||
When wanting to delete an element from the end of an array, you can use [`pop`][pop] method which takes an optional argument specifying how many elements to remove from the end of the array. |
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.
When wanting to delete an element from the end of an array, you can use [`pop`][pop] method which takes an optional argument specifying how many elements to remove from the end of the array. | |
When you want to delete an element from the end of an array, you can use [`pop`][pop] method which takes an optional argument specifying how many elements to remove from the end of the array. |
concepts/array/about.md
Outdated
numbers # => [1, 2] | ||
``` | ||
|
||
When wanting to delete an element of a specific index from an array, you can use the [`delete_at`][delete_at] method which takes the index of the element to remove as an argument. |
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.
When wanting to delete an element of a specific index from an array, you can use the [`delete_at`][delete_at] method which takes the index of the element to remove as an argument. | |
When you want to delete an element of a specific index from an array, you can use the [`delete_at`][delete_at] method which takes the index of the element to remove as an argument. |
concepts/array/about.md
Outdated
|
||
## Modifying values in an array | ||
|
||
When wanting to modify an element of a specific index from an array, you can use the [`[]=` (index assign) operator][index-assign] which takes the index of the element to modify and the new value as arguments. |
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.
When wanting to modify an element of a specific index from an array, you can use the [`[]=` (index assign) operator][index-assign] which takes the index of the element to modify and the new value as arguments. | |
When you want to modify an element of a specific index from an array, you can use the [`[]=` (index assign) operator][index-assign] which takes the index of the element to modify and the new value as arguments. |
concepts/array/about.md
Outdated
numbers # => [1, 2, 3, 4] | ||
``` | ||
|
||
As you can see even though we only modified `other_numbers` so was `numbers` also modified. |
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.
As you can see even though we only modified `other_numbers` so was `numbers` also modified. | |
As you can see even though we only modified `other_numbers`, `numbers` was also modified. |
# => ["Crystal"] | ||
``` | ||
|
||
## 4. Define a function to return the first item in the array |
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.
This doesn't really match the description below
end | ||
|
||
describe "add" do | ||
it "add a language to a array" 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 "add a language to a array" do | |
it "add a language to an array" do |
language_list.should eq ["Crystal"] | ||
end | ||
|
||
it "add several languages to a array" 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 "add several languages to a array" do | |
it "add several languages to an array" do |
it "Can parse a string with only one language" do | ||
language_list = LanguageList.parse("Crystal") | ||
language_list.should eq ["Crystal"] | ||
end | ||
|
||
it "Can parse a string with multiple languages" do | ||
language_list = LanguageList.parse("Crystal, Ruby, C#, Java") | ||
language_list.should eq ["Crystal", "Ruby", "C#", "Java"] | ||
end | ||
|
||
it "Can parse a string with a language made of 2 words" 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 "Can parse a string with only one language" do | |
language_list = LanguageList.parse("Crystal") | |
language_list.should eq ["Crystal"] | |
end | |
it "Can parse a string with multiple languages" do | |
language_list = LanguageList.parse("Crystal, Ruby, C#, Java") | |
language_list.should eq ["Crystal", "Ruby", "C#", "Java"] | |
end | |
it "Can parse a string with a language made of 2 words" do | |
it "can parse a string with only one language" do | |
language_list = LanguageList.parse("Crystal") | |
language_list.should eq ["Crystal"] | |
end | |
it "can parse a string with multiple languages" do | |
language_list = LanguageList.parse("Crystal, Ruby, C#, Java") | |
language_list.should eq ["Crystal", "Ruby", "C#", "Java"] | |
end | |
it "can parse a string with a language made of 2 words" do |
No description provided.