Reputation: 147
I'm just starting out a question on leetcode and i'm just wondering what the syntax of a bit of code means.
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
def add_two_numbers(l1, l2)
end
I'm having trouble understanding what this particular part means.
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
Upvotes: 6
Views: 4501
Reputation: 366
From https://yardoc.org/:
YARD is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions.
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
is the YARD documentation of the add_two_numbers
method. It means that the method takes two parameters (l1
and l2
, both are ListNode
instances) and returns a new ListNode
instance.
Upvotes: 10