Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I know the long hand way of doing this is as follows:

private String var1;

public String getvar1() {
 return var1;
}
public void setvar1(String str) {
 var1 = 'Prefix '+str;
}

The shorthand way is something along the lines of the following but I don't know how the value is passed:

public String var1 {
 get;
 set(String str) {
  this = 'Prefix '+str;
 }
}

As such the set is pseudocode. I would like to know the correct form for this shorthand way of writing the setter.

share|improve this question
1  
Refer here...possible duplicate of salesforce.stackexchange.com/questions/4464/… –  Ganesh Feb 7 at 12:42
add comment

1 Answer

up vote 4 down vote accepted

This should do.

public String var1 {
 get;
 set {
  var1 = value; 
 }
}

You can use 'value', which has the actual input for the setter.

This is clearly described in the documentation

share|improve this answer
1  
Thanks, this works perfectly. I cannot mark this as the answer for another 8 minutes. –  Venko Feb 7 at 12:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.