Lambda
represents using a lambda literal (not the lambda method call).
->(value) { value * 2 }Attributes Public Class Methods Source
def initialize(params:, statements:, location:) @params = params @statements = statements @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(Lambda) && params === other.params && statements === other.statements endSource
def accept(visitor) visitor.visit_lambda(self) endSource
def child_nodes [params, statements] endSource
def copy(params: nil, statements: nil, location: nil) node = Lambda.new( params: params || self.params, statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node endSource
def deconstruct_keys(_keys) { params: params, statements: statements, location: location, comments: comments } endSource
def format(q) params = self.params q.text("->") q.group do if params.is_a?(Paren) q.format(params) unless params.contents.empty? elsif params.empty? && params.comments.any? q.format(params) elsif !params.empty? q.group do q.text("(") q.format(params) q.text(")") end end q.text(" ") q .if_break do q.text("do") unless statements.empty? q.indent do q.breakable_space q.format(statements) end end q.breakable_space q.text("end") end .if_flat do q.text("{") unless statements.empty? q.text(" ") q.format(statements) q.text(" ") end q.text("}") end end end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4