How to resolve the algorithm Reflection/List methods step by step in the Nanoquery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Reflection/List methods step by step in the Nanoquery programming language

Table of Contents

Problem Statement

The goal is to get the methods of an object, as names, values or both. Some languages offer dynamic methods, which in general can only be inspected if a class' public API includes a way of listing them.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Reflection/List methods step by step in the Nanoquery programming language

Source code in the nanoquery programming language

// create a class with methods that will be listed
class Methods
	def static method1()
		return "this is a static method. it will not be printed"
	end
	def method2()
		return "this is not a static method"
	end

	def operator=(other)
		// operator methods are listed by both their defined name and
		// by their internal name, which in this case is isEqual
		return true
	end
end

// lists all nanoquery and java native methods
for method in dir(new(Methods))
	println method
end

  

You may also check:How to resolve the algorithm Search a list step by step in the PHP programming language
You may also check:How to resolve the algorithm Anagrams/Deranged anagrams step by step in the Kotlin programming language
You may also check:How to resolve the algorithm A+B step by step in the Agena programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Old Russian measure of length step by step in the REXX programming language