A colleague of mine states that booleans as method arguments are not acceptable. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example.
What's easier to understand?
file.writeData( data, true…
I would like to declare an enum Direction, that has a method that returns the opposite direction (the following is not syntactically correct, i.e, enums cannot be instantiated, but it illustrates my point). Is this possible in Java?
Here is the…
Are there any standard methods to get Enumeration names by value?
An example:
class Example(enum.Enum):
one = 1
two = 2
ex_variable = 1
Given ex_variable, can I obtain the string contained in Example.one.name?
I'm looking to see if there is an official enumeration for months in the .net framework.
It seems possible to me that there is one, because of how common the use of month is, and because there are other such enumerations in the .net framework.
For…
This question came to my mind, when I had something like
enum Folders {FA, FB, FC};
and wanted to create an array of containers for each folder:
ContainerClass*m_containers[3];
....
m_containers[FA] = ...; // etc.
(Using maps it's much more…
Do you use singular or plural for enumerations? I think it makes best sense with plural in the declaration
enum Weekdays
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
... but I think it makes more…
I want to enumerate through an array in Swift, and remove certain items. I'm wondering if this is safe to do, and if not, how I'm supposed to achieve this.
Currently, I'd be doing this:
for (index, aString: String) in enumerate(array) {
//Some…
I've been using enumerateObjectsUsingBlock: a lot lately for my fast-enumeration needs, and I'm having a hard time understanding the usage of BOOL *stop in the enumeration block.
The NSArray class reference states
stop: A reference to a Boolean…
I'm trying to find a way to iterate through an enum's values while using generics. Not sure how to do this or if it is possible.
The following code illustrates what I want to do. Note that the code T.values() is not valid in the following…
A new feature in C# / .NET 4.0 is that you can change your enumerable in a foreach without getting the exception. See Paul Jackson's blog entry An Interesting Side-Effect of Concurrency: Removing Items from a Collection While Enumerating for…
A friend asked me last week how to enumerate or list all variables within a program/function/etc. for the purposes of debugging (essentially getting a snapshot of everything so you can see what variables are set to, or if they are set at all). I…
In the two following snippets, is the first one safe or must you do the second one?
By safe I mean is each thread guaranteed to call the method on the Foo from the same loop iteration in which the thread was created?
Or must you copy the reference…
An interview question for a .NET 3.5 job is "What is the difference between an iterator and an enumerator"?
This is a core distinction to make, what with LINQ, etc.
Anyway, what is the difference? I can't seem to find a solid definition on the net.…