Class lua - capturing variable assignments

Ruby has this very interesting functionality in which when you create a class with 'Class.new' and assign it to a constant (uppercase), the language "magically" sets up the name of the class so it matches the constant. # This is ruby code MyRubyClass = Class.new(SuperClass) puts MyRubyClass.name # "MyRubyClass" It seems ruby "captures" the assignment and inserts sets the name on the anonymous class. I'd like to know if there's a way to do something similar in Lua. I've implemented my own cl

Should method/class comments be consistently applied or on a need basis only?

For consistency, I've always applied comments (in the form of a JavaDoc) to all methods and classes, even if they are simple getters and setters methods or very small wrapper classes. But I'm also striving to write self-documenting code which often makes comments superfluous; i.e. write comments only where needed (and before doing that, try to rewrite the code so you don't need the comment at all). Hence, these two approaches appear to be contradictory to each other. So should comments which de

Class Dynamic property names in VBA

I have a custom class module in VBA (Access) that is supposed to handle a large amount of external data. Currently I have two functions Read(name) and Write(name, value) that allows to read and set dynamic properties. Is there a way to define a more syntactic way to read and write those data? I know that some objects in VBA have a special way of accessing data, for example the RecordSet, which allows to read and set data using myRS!property_name. Is there a way to do exactly the same for custom

Is this Class Diagram Correct?

I need some help to confirm I am on the right track with this. I did a use case diagram and class diagram for the popular online shopping scenario. Please look through it and criticize constructively, let me have your views on it as I am still learning UML. The story behind the modeling is shown below: The name of the company is X-company and they are into the sales of paints. X-company has a website that sells these paints online to two types of customers - retailers and wholesalers.

cannot calling customMapField class from menu item

i've read this article about this "How to show our own icon in BlackBerry Map?" and i want to put it on my project, and calling the Scr() class from the menu item : MenuItem _openAction = new MenuItem("MyLocation",100000,10) { public void run() { UiApplication.getUiApplication().pushScreen(new Scr()); } }; but i get error ""jvm error 104 uncaught runtime exception" when i calling it from menu "MyLocation". i tried before but i calling the Scr() class from the main scr

Merging two ArrayLists with 2 different objects(which are the instance of the same class)

I just want to merge two ArrayLists and have the contents in one ArrayList. Both lists contain the object which is an instance of the same class. The object reference themselves are different though. However I am getting this unexpected size for the combined arraylist. I use JAVA 1.4 ArrayList a1 = new ArrayList(); ArrayList b1 = new ArrayList(); ClassA cls1A = new ClassA(); ClassA cls1B = new ClassA(); a1.add(cls1A); b1.add(cls1B); a1.size() = 100; b1.size() = 50; //merge the two

Passing arguments to the right inherited class with super()

Let assume that a class inherits 2 classes: one takes 1 argument, the other none. How do I ensure that the argument is passed to the class accepting the argument independently of the order of the subclasses? Specifically, I have problems with this example: class Generic(object): def __init__(self,data): self.data=data def do_data(self): print(self.data) class Generic2(object): def __init__(self): pass def no_data(self): print("No_data") class My

Can you use a class inside of a function in C#

I was wondering if I could use a class inside of a function. I would the call the function in another file using using filename.FuntionName(); I made the class public so that it would more likely cooperate. Also, would using filename.FunctionName(); call the function from the other file, or just use it as a resource? Well, here is the code: namespace file { public void file() { public class file { /*function code*/ } } }

Size of class with static member and accessor

I have a question regarding efficiency. I am writing an app for windows phone 7 and care a lot about memory, as I am using extremely long lists. My question is, what is the size of a class that apart from using normal properties like int, string etc, has also a static int property and an accessor property for the forementioned static field? I need to use a static field, but cannot access it using databinding, thus my question. An example: private static int _property1; public int Property

Class switch(...) in Update() or constructor?

I'm trying to make my first real game in XNA... I've made an Abilities class which keeps track of different abilities a monster or item can have... I also made an enumeration of all the kinds of abilities I want. I was wondering... Would it be better to have just a TypeOfAbility field in my class and a big switch(TypeOfAbility) in my Update() method which would check the type every time and act accordingly, or have a lot of fields, a big switch(TypeOfAbility) in the class constructor, which wou

In Scala, combine objects methods as class methods

I want to combine two libraries, one requires me to extend an abstract class with methods a_1 a_2 ... a_n, b_1, b_2 ... b_m, and the other one provides two objects A and B that respectively implement methods a_i and b_i. Is there an elegant way to combine A and B? Here is what I'm currently doing: class myClass extends abstractClass { def a_1 = A.a_1 def a_2 = A.a_2 ... def b_1 = B.b_1 def b_2 = B.b_2 ... }

TypeScript 0.9.1 CommonJS: correctly declaring exported ambient class implementing external interface?

EDIT: Put another way the following within a .d.ts file shouldn't produce compiler error TS2137 'Class "MyClass" does not implement interface "IInterface"': interface IInterface { someMethod():void; } declare module "mod" { export class MyClass implements IInterface { constructor(); } } because I'm not (and can't in a declaration) implementing anything. Is this a bug in the compiler or is there some other way/syntax to do what the above implies? I would think the compile

Excel VBA: How do I add an item to a collection within a class?

I have a class that contains a collection of itself. (The top level class contains summary versions of the detailed instances in the collection.) Currently the collection is a public variable because I haven't figured out all the details of working with private variables yet. I can fix that later. How do I add items to the collection? I am getting error 91 for missing object variables. Thanks for all prior help. I have been retooling my code to use classes more extensively, and it's really g

Class Magento Conceptual Schema

Had been looking at overall architecture to understand Magento system. -- Design Principle and Pattern used in Magento( Was able to find some blogs) and -- UML diagrams of Magento Architecture( Didn't find anything). For UML related point Was searching for 1) Magento Conceptual Schema. Class Diagram, Activity Diagram, Use case Diagram or any any suggested UML diagram that gives in-depth understanding of Magento Architecture. For example : I want to understand how FPC container are linked to

Uppercase to Lowercase with Sed and character classes

I'd like to convert a string from upper to lower case. I know there are different ways of solving this problem, but I'd like to understand why this command doesn't work: echo "aa" | sed 's/'[:upper:]'/'[:lower:]'/g' Is it a wrong way to use the classes of characters?

Class Object Browser inside the Android Studio

I need to navigate through the whole android api objects inside the Android Studio to find out classes that extend an individual class and also list of class and interfaces that is extended by an individual class in a hierarchy form. In a simple word I need something like visual studio's Object Browser inside the android studio. any solution?

Writing a Python method to reference the Class attribute in the derived class, rather than base class

As someone who worked more in Java, I am having a bit of difficulty wrapping my head around polymorphic references to class attributes in Python. What I would like to do is have a method in the base class which modifies a "static" variable (aka class attribute) of the base class, but when calling the method from the derived class, for the method to modify the class attribute of the derived class, not the base class. Note, I am NOT overriding the method in the derived class. For example, I have

Optional parameter in class initialization

I'm working with Swift, Sprite-Kit and Xcode 6, I have a class declared like this : class Obstacles: SKSpriteNode { init(initTime: Int, speed: CGFloat, positionX: CGFloat, rotationSpeed: CGFloat) { self.initTime = initTime self.rotationSpeed = rotationSpeed self.positionX = positionX super.init(texture: SKTexture(imageNamed: "Rectangle"), color: SKColor.redColor(), size: CGSize(width: 20, height: 20)) self.speed = speed } var initTime:

Class Model Objects In Swift

I'm struggling to design a model that will store results from an algorithm that I'm creating. The current visual structure of the model is to be as follows: Array Of Results (containing a Dictionary where...) _______________|_______________ | | ^ ^ (Key: Letter of Alphabet) (Value: Arr

Is it wrong to have multiple associations between classes?

I'm modeling a college process, in which I have three classes: Student, Subject and Degree Degrees have their own subjects, students have a list of subjects they have passed, and also students should belong to a single degree plan. On a programming perspective, how should I associate a student with his/her degree? Should I pass the degree as a reference to its object, should I make IDs to degrees? Is there a better alternative?

Class Proper way to modify public interface

Let's assume we have a function that returns a list of apples in our warehouse: List<Apple> getApples(); After some lifetime of the application we've found a bug - in rare cases clients of this function get intoxication because some of the apples returned are not ripe yet. However another set of clients absolutely does not care about ripeness, they use this function simply to know about all available apples. Naive way of solving this problem would be to add the 'ripeness' member to an

creating array inside class with size determined by constructor

My question is quite similar to this Declaring an array inside a class, and setting its size with the constructor But i am going to work in racket. So exactly i want to implement a class which represent object polygon (any number of sides). Polygon is exactly determined by number of sides and array of vertices in clockwise order. So my class must contain those attributes. Is there some way to implement this in racket. I am not an expert in racket (i have done only functional programming in ra

Haskell own instance typeclass

I need to declare my own typeclass but I dont understand why there is the (==). data Egg = Soft | Hard instance Eq Egg where (==) I did not find anything where the (==) is used in an instance, only in a class

Difference between an instance of a class and a class representing an instance already?

I use Java as an example but this is more of a general OOP design related question. Lets take the IOExceptions in Java as an example. Why is there a class FileNotFoundException for example? Should not that be an instance of a IOException where the cause is FileNotFound? I would say FileNotFoundException is an instance of IOException. Where does this end? FileNotFoundButOnlyCheckedOnceException, FileNotFoundNoMatterHowHardITriedException..? I have also seen code in projects I worked in where cl

What does it mean if a superclass state is not defined in Lisp?

My superclass is defined as follows: (defclass missionary-state (state) ((missionary-left :initarg :missionary-left :initform nil :accessor missionary-left :documentation "the number of missionaries on the left side of the river") (missionary-right :initarg :missionary-right :initform nil :accessor missionary-right :documentation "the number of missionaries on the right side of the river") (cannibal-left :initarg :cannibal-left :initform nil :accessor cannibal-left :document

Class poLCA ALERT values that are not positive integers

everybody. I am trying to run an LCA using poLCA package. I have six categorical variables, from which one is binary (gender) and the other ones range from 3 to 7 categories. I keep getting an alert message as follows: ALERT: some manifest variables contain values that are not positive integers. For poLCA to run, please recode categorical outcome variables to increment from 1 to the maximum number of outcome categories for each variable. I applied as.integer() and I trie

Flutter - Drawer as sub-class not updating

I'm a fairly inexperienced coder. I have a Drawer which I have created as a separate class. The issue I'm having is the dynamic data for the Drawer is not populating. I am expecting the data being retrieved from Shared Preferences should populate the third line of my view with the value of currUserL. It's being evaluated correctly, and returns the value of currUserL to the console, but is not updated in the Drawer. I've loaded up a about button (triggering the update method) that works when

class create another class and associate with it later delete it, how to show it in UML class diagram?

Let A and B are classes. A is the class which is responsible for creating class B after creating of ,B A is associated with B after some time class A is Delete class B as a example for above scenario consider there is project manager and he is responsible for creating,editing,deleting project from the system i know class A create class b can show in UML as dependency relationship i have two questions how to represent class delete another class so there is both association and dependency

Dafny - Assertion violation after calling class method from Main

I'm writing up some simple code for a class which intializes baseball runs to 0. Its only method is supposed to take in the number of runs as its parameter, and return a bool based on whether the input was larger than the class variable and an int, and the higher of the 2 runs as follows: class Baseball_Runs { var runs : int; constructor() ensures runs == 0; { runs := 0; } method moreRuns (val: int) returns (hasChanged: bool, n

Vue Conditional Class Binding

I am trying to dynamically render class based off actionTypeCreate. This is a method that simply returns a boolean value based off the prop actionType that is passed. I am triggering this method on the mounted hook and confirmed it is returning properly. Now I am trying to return the class value of 'col-md-4' if actionTypeCreate. If not actionTypeCreate I want to return the class 'col-md-6'. This is what I have but it is not working: :class="{toggleActionType : 'col-md-4' ? 'col-md-6'}" I t

Class Haskell type system nuances

I've been getting into the nitty gritty of the haskell typesystem and trying to get at the fine points of type classes. I've learned a heap, but I'm hitting a wall on the following pieces of code. Using these Class and Instance definitions: class Show a => C a where f :: Int -> a instance C Integer where f x = 1 instance C Char where f x = if x < 10 then 'c' else 'd' Why is it that this passes the type checker: g :: C a => a -> Int -> a g x y = f y yes :: C a =>

NoClassDefFoundError: Could not initialize class org.apache.myfaces.shared.util.StreamCharBuffer

I'm deploying a MyFaces app on Tomcat and am getting this error when requesting a page. Both myfaces-api-2.1.9.jar and myfaces-impl.2.1.9.jar are in the WEB-INF/lib folder of my app (my host prevents me from adding them to server/lib), and StreamCharBuffer is in the impl jar. It's hard from the stack trace (shown below) to see what could be causing the error. Would anyone know what the problem might be? Thanks, Neil java.lang.NoClassDefFoundError: Could not initialize class org.apache.myfaces.

Can't make String an instance of a class in Haskell

I'm playing around trying to understand classes in Haskell. I wrote a silly few lines of code to get the hang of it. I wrote a class called Slang that has one function. When I make Integer an instance of my class, it works fine. But when I make String an instance of my class it won't compile. I've been fidgeting with the program based on what the error output tells me but to no avail. I have idea why it work... Here is the code followed by the error: module Practice where class Slang s where

UML class diagram metamodel

Where can I find a simplified class diagram metamodel ? It's for a ATL ATLAS Transformation Language project, I need to transform a entity class diagram to SQL database. thank you .

Initializing an anonymous class with a trait

Can someone help me understand the following behavior? Simply put: what is the difference between the following two cases where... I define a simple class c + trait t scala> class c {val x=true; val y=this.x} defined class c scala> trait t {} defined trait t I can instantiate a new "c with t" scala> new c with t res32: c with t = $anon$1@604f1a67 But I can't instantiate a new "[anonymous class just like c] with t" scala> new {val x=true; val y=this.x} with t <console&g

Class Scala package private with duplicate name in package hierarchy

So I understand that in Scala, you can define something private within the scope of a specific package by adding the modifier private[packagename] where packagename is (obviously) the name of the package that you wish the reference to be private to. So, for instance, let's say I have a package com.mycompany.usefulname with some class that has a field declared private[mycompany] - this will be accessible within all things in the com.mycompany.usefulname, as well as other things like perhaps com.

Swift class omitting brackets with closure: syntactic sugar or something else?

I'm trying to understand why I can omit the round brackets in a class initialization when it takes a block as parameter. Example without the brackets: var block = CCActionCallBlock { () -> Void in NSLog("sedfjsdkl") } And here's the formally correct version with brackets: var block = CCActionCallBlock ( { () -> Void in NSLog("sedfjsdkl") }) Both variants work as expected, there aren't any runtime errors nor compiler warnings. Under which circumstances can I omit the class'

Class Create multiple objects for an object

I have a Students class as below. My aim is to create multiple student objects and assign a couple of marks for each student. The former is done, but the latter-to assign marks for each student object- is confusing for me. As you can see, I also define a Marks class, but I don't know how to create multiple mark objects for each student object. Thanks for your help. public class Students { private int ID; public Marks mark; public static int total Student=1; public Students(int

Class Statistic Calculations in laravel

I'm working on a project for golfstatistics. Right now I made it so far to enter and edit golfstatistics. I'm working with laravel 5 btw. My database schema works like this: Every round you play saves one entry in the round table with information like (date, playid, weather, courseid) for every hole played an entry in the score table is made. There I have a reference to the roundid and information like (score, fairwayhit, greenhit, putts, penalties, ....) No I want to create reports where I

isinstance gets stuck (or infinite loop?) in __init__ from my class python

So I have a class Panini, which I have to initialize, but it keeps getting stuck in the line assert isinstance(stickers, (int, tuple, set, list)), 'invalid stickers' and when I remove the line it gets stuck in the next isinstance, can somebody tell me what I'm doing wrong here? class Panini: def __init__(self, stickers): self.stickers = stickers #test if stickers is integer or a list/tuple/set of integers assert isinstance(stickers, (int, tuple, set, list

How to access a class METHODS within static/class methods?

` class A(object): x = 0 def say_hi(self): pass @staticmethod def say_hi_static(): pass @classmethod def say_hi_class(cls): pass def run_self(self): self.x += 1 print(self.x) # outputs 1 self.say_hi() self.say_hi_static() self.say_hi_class() @staticmethod def run_static(): print(A.x) # outputs 0 # A.say_hi() # wrong A.say_hi_static() A.say_hi_class() @classmethod def run_class(cls): print (cls.x)# outputs 0 # cls.say_hi() # wro

VSCode intellisense - Array of class instances

I'm aware VS code's intellisense is powered by the TypeScript compiler however I'm not writing TypeScript, just good ol' ES2015. Anyway VS Codes intellisense works well with ES6 class's however I'm coming unstuck where i have an array of classes. I dare say this would be out of the realms of the compilers ability but is there any way to write code to make it possible for the compiler to infer the types of objects stored in the array? A best guess as obviously they could be anything. Here's my

The projectDir is invisible from the task class in Gradle script

It is an example of a build.gradle set on an empty freshly created Gradle/Groovy project on IntellJ. I use projectDir here in two places: in task definition and in task class definition. IntelliJ shows me the first use as incorrect - cannot resolve symbol. And it sees the second use as a correct one. group 'test' version '1.0-SNAPSHOT' apply plugin: 'java' apply plugin: 'groovy' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { compile 'org.codehaus.groovy:gro

Structuring Lua classes

I'm constructing a class in Lua that has a number of groups of related functions within it, but am unsure whether there's a better way to structure it. I currently have to develop for a Lua 5.1 environment but am hopeful that Lua 5.3 will be possible in the near future. The class will be used in a number of different Lua programs, so I want something I can just drop in as a single chunk of code (the environment I'm programming for means that modules and require aren't and won't be an option).

  1    2   3   4   5   6  ... 下一页 最后一页 共 15 页