This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A class defined within a method

 
Kasey Tritt
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is really meant by the term "a class defined within a method"? This term is sometimes used in the exam.
Definitions
Local Classes are specific to a block of code. Their visibility is only within the block of their declaration.
Anonymous classes are classes which have no name. They combine the process of definition and instantiation into a single step.
Does anyone know the term "a class defined within a method" refers to a local class or anonymous class or both?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kasey Tritt:
Does anyone know the term "a class defined within a method" refers to a local class or anonymous class or both?

A class defined within a method could be either a local class or an anonymous class. Here is an example where one of each is defined within a method:

You see, both local classes and anonymous classes can be defined within a method. However, in general, when someone is referring to a class defined within a method, I would presume their talking about a local class, which is the first example.
I hope that helps,
Corey
 
Kasey Tritt
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That certainly helps!
Thanks, Corey.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic