|
Yep - eiffel (from what I remember in my uni days) treats everything as an object - which means there is never any confusion.
While I understand the reasons for differentiating between value an reference types, if all types are reference types, then there's no issue as long as the meanings of 'equals' and == etc. are clear.
I've sometimes thought about developing a small application using only classes - e.g. create an Int class, a Bool class etc.
A lot of work to develop the framework - but it would be an interesting exercise - maybe next time I teach a senior IT class it could be their end of term project
|
|
|
|
|
First one its checking for true and in the second one its comparing the actual object and not the value of the object, you'd think they'd both be "true true"
|
|
|
|
|
Mathlab wrote: you'd think they'd both be "true true"
Been watchin' the true-true in theaters?
|
|
|
|
|
The problem is that the Contains() method implements the equality method defined in the object type contained in the collection. As object only has an equals that tests whether or not two value types have the same value (or two reference types point to the same object), which arg1 and arg2 do, the equality test returns true. That is it considers arg1 and arg2 to be identical. The Contains() method should be used for collection objects that implement the IEquatable<t> interface Equals method. This way we can ensure that the correct behaviour for an equality test results. We could, for example, wrap the booleans in objects of a class that does this. That's what I think, but I only program for a hobby so I could be talking rubbish.
anonymous Bot
|
|
|
|
|
I used this article for reference: link
object arg1 = true;
object arg2 = true;
List<object> collection = new List<object>() { arg1 };
The keyword object doesnt make 'arg1' or 'arg2' a reference type, they are both value types. And as the article clearly states
"If the current instance is a value type, the Equals(Object) method tests for value equality. Value equality means the following:
1.The two objects are of the same type.
2.The values of the public and private fields of the two objects are equal."
when checking
bool first = (collection.Contains(arg1));
bool second = (collection.Contains(arg2));
as both the conditions are satisfied obviously 'Contains' will return true.
As i understand this is exactly the same as doing
int a = 1;
int b = 1;
List<int> intcollection = new List<int>() {a };
bool first = (intcollection.Contains(a));
bool second = (intcollection.Contains(b));
Console.WriteLine(string.Format("{0} {1}", first, second));
in which case we all agree that 'True True' is the output.
I think the confusion occurs because of the tendency to assume object arg1 and object arg2 as reference types. I understand this can cause confusion and bigger underlying problems in a framework scenario but the only reason(AFAIK) causing this is whoever coded it dint realize this beforehand.
but i appreciate this post as I know I would never have come across such a ascenario in years.Please feel free to correct me if I am wrong as I am one of the young players only .
|
|
|
|
|
TheCoolCoder wrote: whoever coded it dint realize this beforehand.
in fact, when the framework was written, I think there were only a very limited number of objects that were intended to be passed - and all of these would have been reference objects. So, not necessarily that he didn't realise it, but more that he didn't consider anyone might try to pass a bunch of booleans!
TheCoolCoder wrote: the tendency to assume object arg1 and object arg2 as reference types.
Spot on! Looked at in isolation, that is exactly what most people assume (myself included!).
This would be a great example of where TDD would possibly have been useful - as in setting up tests with a variety of parameter types, this issue may have been spotted before going into production!
|
|
|
|
|
2 questions:
1. what is the problem, nothing really surprising in your program behaviors... (except, maybe newbie might be surprised by "((object)"A") != "A"")
2. your program doesn't seem to match your 1 line English sentence above?!?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
2 answers
1. The problem is that it is easy to be misled about what is happening in this sort of circumstance; Bearing in mind that, in the real world, the 'contains' code would be in a method that simply has a collection of objects as its parameter (so it's not obvious what values may be in those objects). If you are just saying that you would never be fooled by something like 'contains' finding some objects and not others, then I bow to your superior intellect.
Oh, and the newbies being surprised thing is just off topic. I am certain that many a newbie (and quite a few oldies)_ would be fooled by the 'contains' issue with a mixture of objects, some of which are value and some reference, ESPECIALLY as the issue (in the case identified in some of my other responses) rears its head only when the values of two arguments happens to be equal - which leads to an irregular failure of a part of the framework.
2. Are you referring to 'a trick for young players'? If so, maybe this is an Aussie phrase. It means 'something to beware of for the inexperienced'
|
|
|
|
|
string newUrl = string.Concat("https://", HttpContext.Current.Request.Url.ToString().Replace("http://", string.Empty));
|
|
|
|
|
My theory: sometimes "http://" is found in the current request URL, and sometimes it is not. If you always replace it with nothing, and then prepend "https://", you'll always get what you want.
|
|
|
|
|
This piece of spam is the most inspiring piece I have seen in a while. The sheer complexity, the audacity, the eloquence;
M.FISH *somefool*@midohio.twcbc.com
to undisclosed recipients
Congratulations you Email ID have won 700,000 GBP from Chevrolet motors.
fill the information and send back for processing
1Name....
2Address....
3Telephone Number...
4Sex..:
5Age...
6. Current City....:
7. Occupation
Bank Name....:
Account Name....:
Account Number....:
Bank Address
Today, the spammers think I'm an idiot.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hehe hehe. AspDotNet left a really interesting link in a thread in this forum somewhere. It basically says that they're far more clever than we give them credit for. By sending out something so obviously bogus, you'll only get replied to by the most gullible individuals. This means you can spend all of your precious time working on the people you're most likely to be successful with. It was certainly an eye-opener for me and the only reason it didn't seem obvious was that they seem to get passed-off as entirely inept; incapable of such calculated targeting of their core-demographic.
I hate them to pieces, but I'll admit a new-found respect of sorts, for them.
http://research.microsoft.com/pubs/167719/WhyFromNigeria.pdf[^]
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Why don't we turn the table on them? Send back a reply that you live under a bridge and are responding with a stolen phone. You could sure use the money they promise you and would gladly help. Unfortunately you can't open a bank account without a minimum deposit of (pick a suitable amount).
Perhaps there are gullible scammers as well.
Edit: What kind of person could be upset enough to downvote this? Anyway, a nice 'good morning' goes to Nigeria today!
modified 1-Nov-12 4:04am.
|
|
|
|
|
|
Thank you, Mr. Scammer, you are my last hope. The bridges here at the polar circle are very cold and drafty and I will probably not survive the coming winter. By your message I can see that you also have encountered hard times, so I'm more than willing to help. Unfortunately the banks here will not let homeless people open a bank account unless a minimum deposit of 500$ is made. If you can help me over this obstacle, we can then quickly see to bringing your money to safety.
(I hope the monitor survived the next shower)
|
|
|
|
|
For some reason that still reminds me of the sketch whereby someone was rung at home by a telemarketer. He apologised and said that unfortunately he was very busy, thanked them for the call and asked for their home number so he could call back later to discuss it further at a time it was convenient. They resisted and resisted until finally he asked "Oh, I guess you don't like people calling you at home then?" - the answer was clearly affirmative, before he retorted "Yeah well, I'm at home right now!" (it was Seinfeld)
I did that to a company trying to sell water-coolers once. The sound of the girl's voice after I did the same thing was priceless. I still get a giggle from time-to-time about it now, some 15 years later.
I'll be sure to report back here with any ensuing hilarity. Thanks for the idea.
Edit: meant to say the monitor's fine, it's just the front of these shorts that suffered..
Make it work. Then do it better - Andrei Straut
modified 30-Oct-12 12:55pm.
|
|
|
|
|
Makes no sense - you're not falling into their core demographics - extremely gullible people but which _do_ have some money.
OTOH, giving out a real account number cannot harm you - no bank will make payments from your account without some sort of proof that you authorized the payment - such as a signed payment order or an electronically authenticated transfer, so your account should be safe as long as you don't pass confidential info on to the scammer.
|
|
|
|
|
|
The only problem with replying with anything is that you establish that your e-mail is valid and active. This will be distributed to other spammers that they've found an idiot and your spam mail will increase 10-fold
|
|
|
|
|
|
It's worth a try. A friend of mine managed to talk a spammer into sending him a check years ago. It was a real Bank of Something or Other cashiers check.
(A check that was part of a stolen shipment of blanks and was filled out by the spammer not the bank; but nonetheless it was a real check.)
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
I think its a good idea. I will sometimes waste a little bit of time and ask them to forward the routing # and account # where I can pick up the money. I tell them that I don't disclose any information over email. I have yet to hear back, but I guess there is a certain amount of personal satisfaction anyway.
|
|
|
|
|
CDP1802 wrote: Perhaps there are gullible scammers as well.
We just need a source of guaranteed-to-be-fake account and routing numbers we can use to reply with. Or.. [snicker] the account and routing numbers of other scammers (Ok, that last bit's a joke because it would be breaking the law, but it would be funny).
Heck, maybe interpol could hook the false account numbers up to a trap that automatically freezes the assets of the money's destination.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Seems like some nigerian jerks are trying to downvote your post
|
|
|
|
|
You give away most of that information every time you write a check.
If you're wearing your McDonald's outfit when you write the check, they've got all of it.
|
|
|
|