Skip to content
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

Merged
merged 8 commits into from
Oct 9, 2023
Merged

Conversation

meatball133
Copy link
Member

No description provided.


## Empty Arrays

When creating an empty array, can the compiler not infer which type the array is built of.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines 61 to 62
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`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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`.


## 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.


## 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.


## 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

numbers # => [1, 2, 3, 4]
```

As you can see even though we only modified `other_numbers` so was `numbers` also modified.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it "add several languages to a array" do
it "add several languages to an array" do

Comment on lines 73 to 83
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

@ryanplusplus ryanplusplus merged commit 62cce48 into exercism:main Oct 9, 2023
8 checks passed
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