Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

2253-1 #179

Open
wants to merge 170 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
ab6456f
Create about_array_assignment.rb
Ctalk3r Jul 8, 2018
b69b59d
Add files via upload
Ctalk3r Jul 8, 2018
0d7de85
Update triangle.rb
Ctalk3r Jul 8, 2018
4f3bd83
Update triangle.rb
Ctalk3r Jul 8, 2018
7598c3e
Update triangle.rb
Ctalk3r Jul 8, 2018
19cf67e
Update about_true_and_false.rb
Ctalk3r Jul 8, 2018
144ea09
Update about_true_and_false.rb
Ctalk3r Jul 8, 2018
085963d
Update about_true_and_false.rb
Ctalk3r Jul 8, 2018
bf463f2
Update about_triangle_project_2.rb
Ctalk3r Jul 8, 2018
01276d2
Update about_triangle_project_2.rb
Ctalk3r Jul 8, 2018
fd22b25
Update about_to_str.rb
Ctalk3r Jul 8, 2018
c521d7c
Update about_triangle_project.rb
Ctalk3r Jul 8, 2018
0c3d9a4
Update about_to_str.rb
Ctalk3r Jul 8, 2018
7890e9c
Update about_array_assignment.rb
Ctalk3r Jul 8, 2018
bd82f66
Update about_to_str.rb
Ctalk3r Jul 8, 2018
625b481
Update triangle.rb
Ctalk3r Jul 8, 2018
a3c5e91
Update about_strings.rb
Ctalk3r Jul 8, 2018
962779b
Update about_regular_expressions.rb
Ctalk3r Jul 8, 2018
09fe24e
Update about_regular_expressions.rb
Ctalk3r Jul 8, 2018
5cc5e5c
Update about_regular_expressions.rb
Ctalk3r Jul 8, 2018
aae35e9
Update about_sandwich_code.rb
Ctalk3r Jul 8, 2018
a98481c
Update about_sandwich_code.rb
Ctalk3r Jul 8, 2018
cd7a86a
Update triangle.rb
Ctalk3r Jul 9, 2018
e56988d
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
5860b48
Update about_sandwich_code.rb
Ctalk3r Jul 9, 2018
a6014b5
Update about_true_and_false.rb
Ctalk3r Jul 9, 2018
35450b3
Update about_iteration.rb
Ctalk3r Jul 9, 2018
10affeb
Update about_iteration.rb
Ctalk3r Jul 9, 2018
7ca09ff
Update about_proxy_object_project.rb
Ctalk3r Jul 9, 2018
8f8f3d8
Update about_proxy_object_project.rb
Ctalk3r Jul 9, 2018
e3b5935
Update about_to_str.rb
Ctalk3r Jul 9, 2018
8551d80
Update about_symbols.rb
Ctalk3r Jul 9, 2018
bf43352
Update about_methods.rb
Ctalk3r Jul 9, 2018
1c03b6f
Update about_symbols.rb
Ctalk3r Jul 9, 2018
9f3f0e1
Update about_scoring_project.rb
Ctalk3r Jul 9, 2018
a9e0b5e
Update about_control_statements.rb
Ctalk3r Jul 9, 2018
1260d9f
Update triangle.rb
Ctalk3r Jul 9, 2018
442cf61
Update about_symbols.rb
Ctalk3r Jul 9, 2018
6a07d69
Update about_message_passing.rb
Ctalk3r Jul 9, 2018
ca2b1a4
Update about_inheritance.rb
Ctalk3r Jul 9, 2018
3c7b6e8
Update about_symbols.rb
Ctalk3r Jul 9, 2018
285abe0
Update about_nil.rb
Ctalk3r Jul 9, 2018
4d41b4c
Update about_symbols.rb
Ctalk3r Jul 9, 2018
a46494e
Update about_strings.rb
Ctalk3r Jul 9, 2018
091c805
Update about_keyword_arguments.rb
Ctalk3r Jul 9, 2018
16f4252
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
0be4ee6
Update about_proxy_object_project.rb
Ctalk3r Jul 9, 2018
e104648
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
6a3fe89
Update about_symbols.rb
Ctalk3r Jul 9, 2018
91e555f
Update about_strings.rb
Ctalk3r Jul 9, 2018
318811d
Update about_iteration.rb
Ctalk3r Jul 9, 2018
866ac1c
Update about_methods.rb
Ctalk3r Jul 9, 2018
2f2b933
Update about_scope.rb
Ctalk3r Jul 9, 2018
c13893b
Update about_asserts.rb
Ctalk3r Jul 9, 2018
d876128
Update about_class_methods.rb
Ctalk3r Jul 9, 2018
5ffdd86
Update about_strings.rb
Ctalk3r Jul 9, 2018
9fb42f6
Update about_control_statements.rb
Ctalk3r Jul 9, 2018
5e28805
Update about_objects.rb
Ctalk3r Jul 9, 2018
b8802af
Update about_nil.rb
Ctalk3r Jul 9, 2018
2f381aa
Update about_array_assignment.rb
Ctalk3r Jul 9, 2018
6bbdc2f
Update about_strings.rb
Ctalk3r Jul 9, 2018
68a07a7
Update about_sandwich_code.rb
Ctalk3r Jul 9, 2018
8588cf8
Update about_scoring_project.rb
Ctalk3r Jul 9, 2018
23cf485
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
3314454
Update about_hashes.rb
Ctalk3r Jul 9, 2018
b7f7054
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
845a4a0
Update about_scoring_project.rb
Ctalk3r Jul 9, 2018
d01deb3
Update about_strings.rb
Ctalk3r Jul 9, 2018
38a2442
Update about_message_passing.rb
Ctalk3r Jul 9, 2018
b324786
Update about_strings.rb
Ctalk3r Jul 9, 2018
133ce16
Update about_modules.rb
Ctalk3r Jul 9, 2018
eaa1f33
Update about_open_classes.rb
Ctalk3r Jul 9, 2018
5fefd19
Update about_proxy_object_project.rb
Ctalk3r Jul 9, 2018
81710ad
Update about_dice_project.rb
Ctalk3r Jul 9, 2018
6117e4e
Update about_strings.rb
Ctalk3r Jul 9, 2018
c4cfe52
Update about_symbols.rb
Ctalk3r Jul 9, 2018
a70d1bc
Update about_open_classes.rb
Ctalk3r Jul 9, 2018
a8c121d
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
a0ef8ee
Update about_hashes.rb
Ctalk3r Jul 9, 2018
6d229bd
Update about_regular_expressions.rb
Ctalk3r Jul 9, 2018
830cbf4
Update about_exceptions.rb
Ctalk3r Jul 9, 2018
8272dd0
Update about_inheritance.rb
Ctalk3r Jul 9, 2018
85b69dd
Update about_class_methods.rb
Ctalk3r Jul 10, 2018
60f30f4
Update about_hashes.rb
Ctalk3r Jul 10, 2018
d5c4ade
Update about_dice_project.rb
Ctalk3r Jul 10, 2018
6454d5f
Update about_message_passing.rb
Ctalk3r Jul 10, 2018
61d5c5a
Update about_modules.rb
Ctalk3r Jul 10, 2018
010dca3
Update about_nil.rb
Ctalk3r Jul 10, 2018
5cd8a6f
Update about_methods.rb
Ctalk3r Jul 10, 2018
6047b87
Update about_control_statements.rb
Ctalk3r Jul 10, 2018
fd8dca1
Update about_exceptions.rb
Ctalk3r Jul 10, 2018
cbb08dd
Update about_dice_project.rb
Ctalk3r Jul 10, 2018
0bd0ca4
Update about_methods.rb
Ctalk3r Jul 10, 2018
79eea7a
Update about_exceptions.rb
Ctalk3r Jul 10, 2018
4edf28e
Update about_class_methods.rb
Ctalk3r Jul 10, 2018
67a8d88
Update about_methods.rb
Ctalk3r Jul 10, 2018
59ab1b9
Update about_constants.rb
Ctalk3r Jul 10, 2018
40b1bd1
Update about_dice_project.rb
Ctalk3r Jul 10, 2018
f5bae46
Update about_control_statements.rb
Ctalk3r Jul 10, 2018
7f5e5e9
Update about_class_methods.rb
Ctalk3r Jul 10, 2018
2ecf881
Update about_arrays.rb
Ctalk3r Jul 10, 2018
2760bb6
Update about_exceptions.rb
Ctalk3r Jul 10, 2018
7f66061
Update about_dice_project.rb
Ctalk3r Jul 10, 2018
52c0bd9
Update about_array_assignment.rb
Ctalk3r Jul 10, 2018
b0abb8b
Update about_arrays.rb
Ctalk3r Jul 10, 2018
d10f58d
Update about_blocks.rb
Ctalk3r Jul 10, 2018
8329c80
Update about_classes.rb
Ctalk3r Jul 10, 2018
7fa83ff
Update about_control_statements.rb
Ctalk3r Jul 10, 2018
e88d10b
Update about_methods.rb
Ctalk3r Jul 10, 2018
e453089
Update about_constants.rb
Ctalk3r Jul 10, 2018
cc653c4
Update about_constants.rb
Ctalk3r Jul 10, 2018
c62a334
Update about_blocks.rb
Ctalk3r Jul 10, 2018
46ed271
Update about_classes.rb
Ctalk3r Jul 10, 2018
10f114f
Update about_class_methods.rb
Ctalk3r Jul 10, 2018
1050819
Update about_asserts.rb
Ctalk3r Jul 10, 2018
6ceb5fe
Update about_dice_project.rb
Ctalk3r Jul 10, 2018
90423be
Update about_classes.rb
Ctalk3r Jul 10, 2018
772578f
Update about_classes.rb
Ctalk3r Jul 10, 2018
5a40382
Update about_classes.rb
Ctalk3r Jul 10, 2018
8269a35
Update about_inheritance.rb
Ctalk3r Jul 10, 2018
464945d
Update about_proxy_object_project.rb
Ctalk3r Jul 10, 2018
b22284f
Update about_scoring_project.rb
Ctalk3r Jul 10, 2018
4512926
Update about_classes.rb
Ctalk3r Jul 11, 2018
dfc0aef
Update about_constants.rb
Ctalk3r Jul 11, 2018
0b84da3
Update about_dice_project.rb
Ctalk3r Jul 11, 2018
b0ba43d
Update about_exceptions.rb
Ctalk3r Jul 11, 2018
42fb954
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
7e23db2
Update about_regular_expressions.rb
Ctalk3r Jul 11, 2018
73fd4d1
Update about_strings.rb
Ctalk3r Jul 11, 2018
ffb3e5e
Update about_true_and_false.rb
Ctalk3r Jul 11, 2018
c1e8cac
Update about_control_statements.rb
Ctalk3r Jul 11, 2018
b6749fe
Update about_class_methods.rb
Ctalk3r Jul 11, 2018
3cf3172
Update about_exceptions.rb
Ctalk3r Jul 11, 2018
0788178
Update about_constants.rb
Ctalk3r Jul 11, 2018
de3d8a1
Update about_methods.rb
Ctalk3r Jul 11, 2018
6d96858
Update about_symbols.rb
Ctalk3r Jul 11, 2018
5cb7c47
Update about_scoring_project.rb
Ctalk3r Jul 11, 2018
7b5a9d8
Update about_class_methods.rb
Ctalk3r Jul 11, 2018
5ebe714
Update about_hashes.rb
Ctalk3r Jul 11, 2018
22b6e81
Update about_strings.rb
Ctalk3r Jul 11, 2018
4ac0a16
Update about_regular_expressions.rb
Ctalk3r Jul 11, 2018
da7537b
Update about_proxy_object_project.rb
Ctalk3r Jul 11, 2018
370d655
Update triangle.rb
Ctalk3r Jul 11, 2018
6bd10e2
Update about_keyword_arguments.rb
Ctalk3r Jul 11, 2018
95467d2
Update about_dice_project.rb
Ctalk3r Jul 11, 2018
15035eb
Update about_methods.rb
Ctalk3r Jul 11, 2018
cd80220
Add files via upload
Ctalk3r Jul 11, 2018
4960d43
Update about_exceptions.rb
Ctalk3r Jul 11, 2018
136ae1c
Update about_keyword_arguments.rb
Ctalk3r Jul 11, 2018
64edb48
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
31f0a31
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
7cd6866
Update about_regular_expressions.rb
Ctalk3r Jul 11, 2018
f188d56
Update about_symbols.rb
Ctalk3r Jul 11, 2018
b7a5048
Update triangle.rb
Ctalk3r Jul 11, 2018
040f3b6
Update about_proxy_object_project.rb
Ctalk3r Jul 11, 2018
0d66177
Update about_proxy_object_project.rb
Ctalk3r Jul 11, 2018
dec30d7
Update about_symbols.rb
Ctalk3r Jul 11, 2018
b6310e1
Update about_regular_expressions.rb
Ctalk3r Jul 11, 2018
6240d15
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
67ab697
Update about_exceptions.rb
Ctalk3r Jul 11, 2018
57d1e02
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
d8a396d
Update about_keyword_arguments.rb
Ctalk3r Jul 11, 2018
9e2c25c
Update about_class_methods.rb
Ctalk3r Jul 11, 2018
e0b8637
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
28d3d83
Update about_proxy_object_project.rb
Ctalk3r Jul 11, 2018
cabfb50
Update about_proxy_object_project.rb
Ctalk3r Jul 11, 2018
789d6ea
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
c4f48fc
Update about_message_passing.rb
Ctalk3r Jul 11, 2018
0771e28
Update about_proxy_object_project.rb
Ctalk3r Jul 11, 2018
03d4cdb
Update triangle.rb
Ctalk3r Jul 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions 2253/1/about_array_assignment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require File.expand_path(File.dirname(__FILE__) + '/neo')

# :nodoc:
class AboutArrayAssignment < Neo::Koan
# rubocop:disable Style/WordArray
# rubocop:disable Style/ParallelAssignment
def test_non_parallel_assignment
names = ['John', 'Smith']
assert_equal ['John', 'Smith'], names
end

def test_parallel_assignments
first_name, last_name = ['John', 'Smith']
assert_equal 'John', first_name
assert_equal 'Smith', last_name
end

def test_parallel_assignments_with_extra_values
first_name, last_name = ['John', 'Smith', 'III']
assert_equal 'John', first_name
assert_equal 'Smith', last_name
end

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']
assert_equal 'Cher', first_name
assert_equal nil, last_name
end

def test_parallel_assignments_with_subarrays
first_name, last_name = [['Willie', 'Rae'], 'Johnson']
assert_equal ['Willie', 'Rae'], first_name
assert_equal 'Johnson', last_name
end

def test_parallel_assignment_with_one_variable
first_name, = ['John', 'Smith']
assert_equal 'John', first_name
end

def test_swapping_with_parallel_assignment
first_name = 'Roy'
last_name = 'Rob'
first_name, last_name = last_name, first_name
assert_equal 'Rob', first_name
assert_equal 'Roy', last_name
end
# rubocop:enable Style/ParallelAssignment
# rubocop:enable Style/WordArray
end
84 changes: 84 additions & 0 deletions 2253/1/about_arrays.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
require File.expand_path(File.dirname(__FILE__) + '/neo')

# :nodoc:
class AboutArrays < Neo::Koan
def test_creating_arrays
empty_array = []
assert_equal Array, empty_array.class
assert_equal 0, empty_array.size
end

def test_array_literals
array = []
assert_equal [], array

array[0] = 1
assert_equal [1], array

array[1] = 2
assert_equal [1, 2], array

array << 333
assert_equal [1, 2, 333], array
end

def test_accessing_array_elements
array = %i[peanut butter and jelly]

assert_equal :peanut, array[0]
assert_equal :peanut, array.first
assert_equal :jelly, array[3]
assert_equal :jelly, array.last
assert_equal :jelly, array[-1]
assert_equal :butter, array[-3]
end

def test_slicing_arrays
array = %i[peanut butter and jelly]

assert_equal [:peanut], array[0, 1]
assert_equal %i[peanut butter], array[0, 2]
assert_equal %i[and jelly], array[2, 2]
assert_equal %i[and jelly], array[2, 20]
assert_equal [], array[4, 0]
assert_equal [], array[4, 100]
assert_equal nil, array[5, 0]
end

def test_arrays_and_ranges
assert_equal Range, (1..5).class
assert_not_equal [1, 2, 3, 4, 5], (1..5)
assert_equal [1, 2, 3, 4, 5], (1..5).to_a
assert_equal [1, 2, 3, 4], (1...5).to_a
end

def test_slicing_with_ranges
array = %i[peanut butter and jelly]

assert_equal %i[peanut butter and], array[0..2]
assert_equal %i[peanut butter], array[0...2]
assert_equal %i[and jelly], array[2..-1]
end

def test_pushing_and_popping_arrays
array = [1, 2]
array.push(:last)

assert_equal [1, 2, :last], array

popped_value = array.pop
assert_equal :last, popped_value
assert_equal [1, 2], array
end

def test_shifting_arrays
array = [1, 2]
array.unshift(:first)

assert_equal [:first, 1, 2], array

shifted_value = array.shift
assert_equal :first, shifted_value
assert_equal [1, 2], array
end
end
37 changes: 37 additions & 0 deletions 2253/1/about_asserts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require File.expand_path(File.dirname(__FILE__) + '/neo')

# :nodoc:
class AboutAsserts < Neo::Koan
# We shall contemplate truth by testing reality, via asserts.
def test_assert_truth
assert true # This should be true
end

# Enlightenment may be more easily achieved with appropriate
# messages.
def test_assert_with_message
assert true, 'This should be true -- Please fix this'
end

# To understand reality, we must compare our expectations against
# reality.
def test_assert_equality
expected_value = 2
actual_value = 1 + 1

assert expected_value == actual_value
end

# Some ways of asserting equality are better than others.
def test_a_better_way_of_asserting_equality
expected_value = 2
actual_value = 1 + 1

assert_equal expected_value, actual_value
end

# Sometimes we will ask you to fill in the values
def test_fill_in_values
assert_equal 2, 1 + 1
end
end
96 changes: 96 additions & 0 deletions 2253/1/about_blocks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
require File.expand_path(File.dirname(__FILE__) + '/neo')

# :nodoc:
class AboutBlocks < Neo::Koan
def method_with_block
result = yield
result
end

def test_methods_can_take_blocks
yielded_result = method_with_block { 1 + 2 }
assert_equal 3, yielded_result
end

def test_blocks_can_be_defined_with_do_end_too
yielded_result = method_with_block { 1 + 2 }
assert_equal 3, yielded_result
end

# ------------------------------------------------------------------

def method_with_block_arguments
yield('Jim')
end

def test_blocks_can_take_arguments
method_with_block_arguments do |argument|
assert_equal 'Jim', argument
end
end

# ------------------------------------------------------------------

def many_yields
yield(:peanut)
yield(:butter)
yield(:and)
yield(:jelly)
end

def test_methods_can_call_yield_many_times
result = []
many_yields { |item| result << item }
assert_equal %i[peanut butter and jelly], result
end

# ------------------------------------------------------------------

def yield_tester
if block_given?
yield
else
:no_block
end
end

def test_methods_can_see_if_they_have_been_called_with_a_block
assert_equal(:with_block, yield_tester { :with_block })
assert_equal :no_block, yield_tester
end

# ------------------------------------------------------------------

def test_block_can_affect_variables_in_the_code_where_they_are_created
value = :initial_value
method_with_block { value = :modified_in_a_block }
assert_equal :modified_in_a_block, value
end

def test_blocks_can_be_assigned_to_variables_and_called_explicitly
add_one = ->(n) { n + 1 }
assert_equal 11, add_one.call(10)

# Alternative calling syntax
assert_equal 11, add_one[10]
end

def test_stand_alone_blocks_can_be_passed_to_methods_expecting_blocks
make_upper = ->(n) { n.upcase }
result = method_with_block_arguments(&make_upper)
assert_equal 'JIM', result
end

# ------------------------------------------------------------------

def method_with_explicit_block
yield(10)
end

def test_methods_can_take_an_explicit_block_argument
assert_equal(20, method_with_explicit_block { |n| n * 2 })

add_one = ->(n) { n + 1 }
assert_equal 11, method_with_explicit_block(&add_one)
end
end
Loading