Skip to content

Commit

Permalink
renamed Enumerable#uniq => Enumerable#unique
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkdoor committed Apr 25, 2012
1 parent b799520 commit 5141662
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lib/enumerable.fy
Expand Up @@ -377,23 +377,23 @@ class Fancy {
reduce: block init_val: val
}

def uniq {
def unique {
"""
@return @Array@ of all unique elements in @self.
Returns a new Array with all unique values (double entries are skipped).
Example:
[1,2,1,2,3] uniq # => [1,2,3]
[1,2,1,2,3] unique # => [1,2,3]
"""

uniq_vals = []
unique_vals = []
each: |x| {
unless: (uniq_vals includes?: x) do: {
uniq_vals << x
unless: (unique_vals includes?: x) do: {
unique_vals << x
}
}
uniq_vals
unique_vals
}

def size {
Expand Down
2 changes: 1 addition & 1 deletion lib/rbx/file.fy
Expand Up @@ -109,7 +109,7 @@ class File {
modes_arr each: |m| {
str << (@@open_mode_conversions[m])
}
str uniq join: ""
str unique join: ""
}

def File delete: filename {
Expand Down
4 changes: 2 additions & 2 deletions tests/array.fy
Expand Up @@ -195,9 +195,9 @@ FancySpec describe: Array with: {
arr values_at: [1, 3, 4, 10] . is: [2, 'foo, "bar", nil]
}

it: "returns unique values only" with: 'uniq when: {
it: "returns unique values only" with: 'unique when: {
arr = ['foo, 'bar, "baz", 'foo, "baz", "hello", 1, 0, 0, 1, 'bar, 'foo, "hello"]
arr uniq is: ['foo, 'bar, "baz", "hello", 1, 0]
arr unique is: ['foo, 'bar, "baz", "hello", 1, 0]
}

it: "prepends self to another array" with: '>> when: {
Expand Down
4 changes: 2 additions & 2 deletions tests/string.fy
Expand Up @@ -41,9 +41,9 @@ FancySpec describe: String with: {
}
}

it: "behaves like a collection/sequence via each:" with: 'uniq when: {
it: "behaves like a collection/sequence via each:" with: 'unique when: {
str = "Hello, World!"
str uniq join: "" . is: "Helo, Wrd!"
str unique join: "" . is: "Helo, Wrd!"
}

it: "has all its characters as instances of String class" with: 'all?: when: {
Expand Down

0 comments on commit 5141662

Please sign in to comment.