Last active
December 16, 2015 16:29
-
-
Save Githerdone/5463102 to your computer and use it in GitHub Desktop.
Revisions
-
Githerdone revised this gist
Apr 25, 2013 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,18 +14,17 @@ def pad!(min_size, value = nil) end def pad(min_size, value = nil) if self.count >= min_size return new_array = self.clone else new_array = self.clone size_is = min_size - self.count count = 0 while count < size_is new_array << value count += 1 end return new_array end end end -
Githerdone revised this gist
Apr 25, 2013 . 1 changed file with 9 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,10 @@ def pad!(min_size, value = nil) else size_is = min_size - self.count count = 0 while count < size_is self << value count += 1 end return self end end @@ -19,21 +19,11 @@ def pad(min_size, value = nil) if self.count >= min_size return new_array << self else size_is = min_size - self.count count = 0 while count < size_is new_array << value count += 1 end return new_array end -
Githerdone revised this gist
Apr 25, 2013 . 1 changed file with 19 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,37 +6,37 @@ def pad!(min_size, value = nil) size_is = min_size - self.count count = 0 while count < size_is self << value count += 1 end return self end end def pad(min_size, value = nil) new_array = [] if self.count >= min_size return new_array << self else if self.count != 0 new_array << self size_is = min_size - self.count count = 0 while count < size_is new_array << value count += 1 end else size_is = min_size - self.count count = 0 while count < size_is new_array << value count += 1 end end return new_array end end end -
Githerdone created this gist
Apr 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ class Array def pad!(min_size, value = nil) if self.count >= min_size return self else size_is = min_size - self.count count = 0 while count < size_is self << value count += 1 end return self end end def pad(min_size, value = nil) new_array = [] if self.count >= min_size return new_array << self else if self.count != 0 new_array << self size_is = min_size - self.count count = 0 while count < size_is new_array << value count += 1 end else size_is = min_size - self.count count = 0 while count < size_is new_array << value count += 1 end end return new_array end end end [1,2,3].pad!(5, "apple")