Jump to content
Jacek Laskowski

Strange thing in System.Generics.Defaults.pas

Recommended Posts

Quote:

 

unit System.Generics.Defaults;

[...]

function GetHashCode_Class(Inst: PSimpleInstance; const Value: TObject): Integer;
begin
  if Value = nil then
    Result := 42
  else
    Result := Value.GetHashCode;
end;

What is this? Why 42? 🙂

 

 

ps. Delphi Tokyo, maybe other too

Share this post


Link to post

Because 42 is the answer to the ultimate question of life, the universe and everything

Edited by Sherlock
It is a bit more than just everything.
  • Like 3

Share this post


Link to post

That value is as good as any other value. It just has to adhere to the rule that the same value is returned every time when the same input value is supplied. 

Edited by David Heffernan
  • Like 1

Share this post


Link to post
50 minutes ago, santiago said:

42 in binary is 101010

Maybe that is why they chose that number. Just a guess though...

Why not 10101010? Or 1010101010? Or 1010? Or 10? 

Share this post


Link to post
On 12/5/2018 at 5:02 PM, Tom Chamberlain said:

It is all explained here

You meant " The angle rounded to whole degrees for which a rainbow appears (the critical angle). ", right?

🌈🦄

 

Edited by Rudy Velthuis
Everything for or users

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×