Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:45:30+00:00 2026-06-05T10:45:30+00:00

The Rectangle module is defined but why the evaluation R.length and R.area is giving

  • 0
  • The Rectangle module is defined but why the evaluation R.length and R.area is giving error : value area is not a member of Rectangle.
  • Any improvement in defining Rectangle module? Better code?

The Code:

class Rectangle(l:Double, w:Double)
{
    require (l>0, w>0)
    val length = l
    val width = w
    def this (l:Double) = this (l, l)
    def area = (length * width)
}

Scala Interpreter:

class Rectangle(l:Double, w:Double)


[parsing <console>]
[superaccessors in 7ms]
[selectiveanf in 0ms]
[erasure in 4ms]
[Generate ICode from the AST in 5ms]
[inliner in 0ms]
defined class Rectangle


val R = new Rectangle (12, 12)

[parsing <console>]
[erasure in 6ms]
[lazyvals in 0ms]
[Generating icode for <console>]
[Generate ICode from the AST in 4ms]
[inliner in 0ms]
R: Rectangle = Rectangle@117cc9d


val l = println("Rectangle length is " + R.length)

[parsing <console>]
[loaded class file /home/optimight/.eclipse/org.eclipse.platform_3.7.0_155965261/      configuration/org.eclipse.osgi/bundles/201/1/.cp/lib/scala-library.jar(scala/collection/TraversableOnce.class) in 0ms]
[loaded class file /home/optimight/.eclipse/org.eclipse.platform_3.7.0_155965261/configuration/org.eclipse.osgi/bundles/201/1/.cp/lib/scala-library.jar(scala/collection/immutable/IndexedSeq.class) in 0ms]
[total in 44ms]

val A = R.area

[parsing <console>]
<console>:9: error: value area is not a member of Rectangle

The image is showing complete code of Rectangle and scala interpreter in Eclipse Scala IDE.

Please guide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:45:32+00:00Added an answer on June 5, 2026 at 10:45 am

    After a quick look at the screenshot in hires (here), it seems that you don’t really use the class you have defined in the interpreter.
    Either the Rectangle class is loaded when the interpreter start and you redefine it when you typed: class Rectangle(l: double, w: double). Either the class is not loaded and you have defined it for the first time.

    In the first case you only have to avoid typing the first line in the interpreter, in the second case, you have to load the class into the interpreter (I’m not familiar with the scala IDE interpreter, so I can’t tell you how to do it).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I am not a veteran programmer i any language. But I've
In this Haskell code the constructor arguments(length and width) can be of any data
I have a class Shape which should have area defined on all instances. area
Okay, so this is not the first time I've had this problem, but it
The Rectangle element has StrokeDashArray which allows it to be drawn with dashes, but
I have drawn a rectangle with canvas and I wonder if there is any
I wanted a rectangle to move horizontally..However, the rectangle is not animating..How do I
How to make rounded rectangle in OpenGL, or any polygon with rounded corners?
I have defined a rectangle drawable like this: <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <corners android:radius=4dip/> <solid
The common Superclass of Rectangle and Circle is Shape. If I initialize some shapes,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.