I want to write a function that works on any Scala type with a total ordering (i.e. I can use '<' on it). What's the syntax for that? The best I've come up with is
def lessThan[T <: Ordered[T]](x: T, Y: T) = x < y
That doesn't work, though, when I try using it from the REPL:
scala> lessThan(1, 2)
<console>:8: error: inferred type a...
I have an existing Perl application which is deployed to multiple customer sites. Unfortunately, the code has been cloned multiple times to customise it for individual customers. So there are now several complete copies of the code which all have slight (or major) differences.
My task is to fix this mess by creating a single, generic co...
This is a simple test Ruby Shoes program I am talking about: When I try to use the subclass syntax, like class Hello < Shoes and run my program, it complains 'undefined method para' or 'undefined method stack'. Obviously it is not able to subclass Shoes, hence does not know any thing about 'para' or 'stack' methods. However it runs fine,...
In my Java project, I have a vector of various types of Traders. These different types of traders are subclasses of the Trader class. Right now, I have a method that takes a Trader as an argument and stores it 50 or so times in the vector. I am having problems because storing the same object 50 times is just storing 50 references of the ...
I'm implementing an object that is almost identical to a set, but requires an extra instance variable, so I am subclassing the built-in set object. What is the best way to make sure that the value of this variable is copied when one of my objects is copied?
Using the old sets module, the following code worked perfectly:
import sets
cla...
When using drawRect for a UIButton subclass, I never seem to get called to draw the button when hiighlighted. Do I need to call setNeedsDisplay for my button in my touch events?
...
Is am using this:
SetWindowsHookEx(WH_CALLWNDPROC, ...);
I can see the messages I want to process, but I want to prevent those message from reaching the target window. So I tried this:
SetWindowsHookEx(WH_GETMESSAGE, ...);
When I do this I can modify the message, and prevent the target window from processing it, but this hook doesn...
I want to intercept messages that are being sent to a window in a different process. What is the best way to do this? I can't see the messages when I use the WH_GETMESSAGE hook, and I'm not sure if I can subclass across processes? Any help would be much appreciated.
...
After reading lots of blogs, forum entries and several Apple docs, I still don't know whether extensive subclassing in Objective-C is a wise thing to do or not.
Take for example the following case:
Say I'm developing a puzzle game which
has a lot of elements. All of those
elements share a certain amount of the
same behaviour....
I am relatively new to programming with Qt and had a question. Short version:
How do I inherit signals defined in superclasses?
I am trying to subclass someone else's nicely made QTWidgets to change some of the default behavior:
//Plot3D is a QWidget that defines a signal "rotationChanged"
class matLinePlot : public QObject, public...
Is there a way to make the background of a UIView a gradient without subclassing it? I'd rather not use an image file to accomplish this either. It just seems obtuse to have to subclass UIView just to draw a gradient for the background.
...
I have two classes I would like to persist via NHibernate:
- Cat, which has a name and an Id,
- Kitten, which is a subclass of Cat (no extra public properties).
For stupid reasons, I would like to know if it is possible to map Cat only? So that when I persist Kitten, it is saved as a Cat and when I reload it, it is loaded as a Cat.
Add...
Let's say I have an abstract class Drink, and a factory method which chooses the type of Drink (Wine, Beer, etc.) to create at runtime.
Each Drink needs some arguments to properly initialize itself. Some of these are common to all Drinks; for example, they might all require a DrinkConfig argument.
But each Drink may have its own unique...
There appears to be a new pragma named parent that does roughly the same thing as base. What does parent do that warrants a new (non-core) module? I am missing something?
...
When I try to use my iterator class
template<class T>
class list
{
public:
class iterator;
};
template<class T>
class list<T>::iterator
{
//stuff
};
as a return type in an operator overloading,
template<class T>
class list<T>::iterator
{
public:
iterator& operator++();
protected:
list* lstptr;
};
template<class T>
iterator& list<T>...
I'm having a small project in Actionscript 3, and everything would be very much easier if it was possible to call code in the superclass from the subclass.
This is the project:
CarGame
Car
is it possible to call a function in the CarGame class from the Car class?
...
I'm using boto to manage some EC2 instances. It provides an Instance class. I'd like to subclass it to meet my particular needs. Since boto provides a query interface to get your instances, I need something to convert between classes. This solution seems to work, but changing the class attribute seems dodgy. Is there a better way?
from ...
In an iPhone app, I need to customize the look of a UINavigationController class. For instance, make the bar and font size bigger. My client really needs that, and bigger buttons aswell.
So, instead of writing the class from scratch, I decided to subclass UINavigationController. My question is, can I customize any method or attribute's ...
I have a class that is provided to me by an external library. I have created a subclass of this class. I also have an instance of the original class.
I now want to turn this instance into an instance of my subclass without changing any properties that the instance already has (except for those that my subclass overrides anyway).
The fo...
I'm trying to make a subclass of QTableView that has an embedded QLineEdit at the top for filtering the results as-you-type. I need my table to have the same API as a normal QTableView, so I want to subclass it rather than subclassing QWidget and adding a QLineEdit and QTableView to it.
I thought I could just reimplement paintEvent(QPai...