|
W045 Initialized Value in Key
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] W045 Initialized Value in KeyUmple semantic warning reported when an attribute in the key is given an initial valueIf an attribute is given an initial value and is part of a key, then there is potential for keys of all instances of a class to be the same, meaning that they would be treated as equal and would have the same hash value. It is unlikely that a developer intends for this to be the case, so a warning is thrown to inform them of this behaviour. Example
// This example generates the message
class X {
Integer z = 1;
key { z }
}
Load the above code into UmpleOnline Solution to The Above So the Message No Longer Appears
// The following shows how to avoid the message
class X {
Integer z;
key { z }
}
Load the above code into UmpleOnline |