You need to sign in to do that
Don't have an account?
sebipinn
Overloading other methods
Is there a way to set up a parameter in a method to accept anyType? almost how when you use Double.valueOf(anyType) works. I want to do this to my own method where i can accept a string, an integer, or double and return a double after i do some transformations to it.
Is this possible?
Ah nevermind. Looks like it didn't like me doing the following:
public static Double someMethod(Double x) { .. }
public static Double someMethod(Integer x) { .. }
public static Double someMethod(String x) { .. }
It was complaining when i tried to test with an Integer, but apparently Double accepts integers, so I simply had to leave off the Integer one...
public static Double someMethod(Double x) { .. }
public static Double someMethod(String x) { .. }
works just fine
All Answers
Ah nevermind. Looks like it didn't like me doing the following:
public static Double someMethod(Double x) { .. }
public static Double someMethod(Integer x) { .. }
public static Double someMethod(String x) { .. }
It was complaining when i tried to test with an Integer, but apparently Double accepts integers, so I simply had to leave off the Integer one...
public static Double someMethod(Double x) { .. }
public static Double someMethod(String x) { .. }
works just fine
Hi , I have a requirement. I have a numeric field in Account called 'Total_Sum_of_Contacts__c' (parent field) and an other numeric field in Contact called 'Num__c' (child field). The numeric field(Total_Sum_of_Contacts__c) in Account should show the total of all the contacts' numeric field(Num__c). I need to write a trigger. Please someone suggest me a good trigger.
instead of overloading the function you can make it behave the way you want using conditionals and will accept different single param type
Hope this helps!
AM
Can I overload a method with different number of parameters ?