Skip to content

Commit

Permalink
Adding list object type
Browse files Browse the repository at this point in the history
  • Loading branch information
freyamade committed Feb 28, 2019
1 parent 39d8056 commit ab490fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/drizzle/object/list.cr
Original file line number Diff line number Diff line change
@@ -0,0 1,23 @@
require "./object"

module Drizzle
module Object
class List < Object
@elements : Array(Object)

def initialize(@elements)
@object_type = ObjectType::LIST
end

def inspect : String
elements = [] of String
@elements.each do |element|
elements << element.inspect
end
return "[#{elements.join ", "}]"
end

getter elements
end
end
end
2 changes: 2 additions & 0 deletions src/drizzle/object/types.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 20,8 @@ module Drizzle
STRING
# Builtins
BUILTIN
# List
LIST
end
# Type definition for a built in function
alias BuiltinFunction = Proc(Array(Object), Object)
Expand Down

0 comments on commit ab490fe

Please sign in to comment.