Skip to content

Commit 0aa3c5e

Browse files
author
Leon Rische
committed
use snake_case for method and variable names
1 parent 2d84d26 commit 0aa3c5e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Finds the smallest value in an array
2-
def findSmallest(arr)
2+
def find_smallest(arr)
33
# Stores the smallest value
44
smallest = arr[0]
55
# Stores the index of the smallest value
@@ -15,15 +15,15 @@ def findSmallest(arr)
1515
end
1616

1717
# Sort array
18-
def selectionSort(arr)
19-
newArr = []
20-
(0...(arr.length)).each do |i|
18+
def selection_sort(arr)
19+
new_arr = []
20+
arr.length.times do
2121
# Finds the smallest element in the array and adds it to the new array
22-
smallest = findSmallest(arr)
23-
newArr.push(arr.delete_at(smallest))
22+
smallest = find_smallest(arr)
23+
new_arr.push(arr.delete_at(smallest))
2424
end
25-
newArr
25+
new_arr
2626
end
2727

2828
# 'p obj' is the same as 'puts obj.inspect'
29-
p selectionSort([5, 3, 6, 2, 10])
29+
p selection_sort([5, 3, 6, 2, 10])

0 commit comments

Comments
 (0)