mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
Moved splat example to later + several typo corrections.
This commit is contained in:
@@ -5,32 +5,32 @@ class AboutArrayAssignment < EdgeCase::Koan
|
|||||||
names = ["John", "Smith"]
|
names = ["John", "Smith"]
|
||||||
assert_equal __(["John", "Smith"]), names
|
assert_equal __(["John", "Smith"]), names
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parallel_assignments
|
def test_parallel_assignments
|
||||||
first_name, last_name = ["John", "Smith"]
|
first_name, last_name = ["John", "Smith"]
|
||||||
assert_equal __("John"), first_name
|
assert_equal __("John"), first_name
|
||||||
assert_equal __("Smith"), last_name
|
assert_equal __("Smith"), last_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parallel_assigments_with_splat_operator
|
|
||||||
first_name, *last_name = ["John", "Smith", "III"]
|
|
||||||
assert_equal "John", first_name
|
|
||||||
assert_equal ["Smith","III"], last_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_parallel_assignments_with_extra_values
|
def test_parallel_assignments_with_extra_values
|
||||||
first_name, last_name = ["John", "Smith", "III"]
|
first_name, last_name = ["John", "Smith", "III"]
|
||||||
assert_equal __("John"), first_name
|
assert_equal __("John"), first_name
|
||||||
assert_equal __("Smith"), last_name
|
assert_equal __("Smith"), last_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parallel_assignments_with_extra_variables
|
def test_parallel_assignments_with_splat_operator
|
||||||
|
first_name, *last_name = ["John", "Smith", "III"]
|
||||||
|
assert_equal "John", first_name
|
||||||
|
assert_equal ["Smith","III"], last_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_parallel_assignments_with_too_few_variables
|
||||||
first_name, last_name = ["Cher"]
|
first_name, last_name = ["Cher"]
|
||||||
assert_equal __("Cher"), first_name
|
assert_equal __("Cher"), first_name
|
||||||
assert_equal __(nil), last_name
|
assert_equal __(nil), last_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parallel_assignements_with_subarrays
|
def test_parallel_assignments_with_subarrays
|
||||||
first_name, last_name = [["Willie", "Rae"], "Johnson"]
|
first_name, last_name = [["Willie", "Rae"], "Johnson"]
|
||||||
assert_equal __(["Willie", "Rae"]), first_name
|
assert_equal __(["Willie", "Rae"]), first_name
|
||||||
assert_equal __("Johnson"), last_name
|
assert_equal __("Johnson"), last_name
|
||||||
|
|||||||
Reference in New Issue
Block a user