Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created October 16, 2013 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakkdoor/7017002 to your computer and use it in GitHub Desktop.
Save bakkdoor/7017002 to your computer and use it in GitHub Desktop.
diff --git a/lib/array.fy b/lib/array.fy
index a2a06f6..70fc565 100644
--- a/lib/array.fy
+++ b/lib/array.fy
@@ -7,6 +7,23 @@ class Array {
include: Fancy Enumerable
+ method_documentation: <[
+ 'at: => """
+ @idx Index for value to retrieve.
+ @return Value with the given index (if available), or @nil.
+
+ Returns the element in the @Array@ at a given index.
+ """,
+
+ '[]: => """
+ @idx Index to set a value for.
+ @obj Value (object) to be set at the given index.
+ @return @obj.
+
+ Inserts a given object at a given index (position) in the Array.
+ """
+ ]>
+
def Array new: size {
"""
@size Initial size of the @Array@ to be created (values default to @nil).
@@ -81,10 +98,6 @@ class Array {
"""
if: (index is_a?: Fancy Enumerable) then: {
- # start, end = index
- # from: start to: end
- # Avoiding initializing variables in the block to make life easier for
- # the GC.
from: (index[0]) to: (index[1])
} else: {
at: index
diff --git a/lib/object.fy b/lib/object.fy
index a1193ae..be3dd91 100644
--- a/lib/object.fy
+++ b/lib/object.fy
@@ -849,4 +849,18 @@ class Object {
Object
}
+
+ method_documentation: <[
+ 'is_a?: => """
+ @class @Class@ to check for if @self is an instance of.
+ @return @true if @self is an instance of @class, @false otherwise.
+
+ Indicates, if an object is an instance of a given Class.
+ """,
+
+ 'kind_of?: => """
+ Same as Object#is_a?:
+ Indicates, if an object is an instance of a given Class.
+ """
+ ]>
}
diff --git a/lib/rbx/array.fy b/lib/rbx/array.fy
index ed18edc..aecab31 100644
--- a/lib/rbx/array.fy
+++ b/lib/rbx/array.fy
@@ -63,31 +63,9 @@ class Array {
nil
}
- # def at: idx {
- # """
- # @idx Index for value to retrieve.
- # @return Value with the given index (if available), or @nil.
- #
- # Returns the element in the @Array@ at a given index.
- # """
- #
- # at(idx)
- # }
- alias_method: 'at: for: 'at
- alias_method('at_put, '[]=)
-
- def [idx]: obj {
- """
- @idx Index to set a value for.
- @obj Value (object) to be set at the given index.
- @return @obj.
-
- Inserts a given object at a given index (position) in the Array.
- """
-
- at_put(idx, obj)
- }
+ alias_method: 'at: for_ruby: 'at
+ alias_method: '[]: for_ruby: '[]=
alias_method: 'at:put: for: '[]:
diff --git a/lib/rbx/object.fy b/lib/rbx/object.fy
index dc336d8..6a190eb 100644
--- a/lib/rbx/object.fy
+++ b/lib/rbx/object.fy
@@ -79,26 +79,7 @@ class Object {
metaclass undefine_method: name
}
- # def is_a?: class {
- # """
- # @class @Class@ to check for if @self is an instance of.
- # @return @true if @self is an instance of @class, @false otherwise.
- #
- # Indicates, if an object is an instance of a given Class.
- # """
- #
- # is_a?(class)
- # }
alias_method: 'is_a?: for: 'is_a?
-
- # def kind_of?: class {
- # """
- # Same as Object#is_a?:
- # Indicates, if an object is an instance of a given Class.
- # """
- #
- # kind_of?(class)
- # }
alias_method: 'kind_of?: for: 'kind_of?
def receive_message: message {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment