Skip to content

Instantly share code, notes, and snippets.

@shemnon
Last active October 4, 2018 15:10
Show Gist options
  • Save shemnon/82b77b633ccbc7fa2adc8c4380e68edf to your computer and use it in GitHub Desktop.
Save shemnon/82b77b633ccbc7fa2adc8c4380e68edf to your computer and use it in GitHub Desktop.
Comparison of property access patterns and JVM language integrations.
package com.example.java;
public class DemoClass {
public String fieldProperty = "init";
private String _cppProperty = "init";;
private String _javaProperty = "init";;
public String cppProperty() {
return _cppProperty;
}
public void cppProperty(String newCppProperty) {
_cppProperty = newCppProperty;
}
public String getJavaProperty() {
return _javaProperty;
}
public void setJavaProperty(String newJavaProperty) {
_javaProperty = newJavaProperty;
}
}
package com.example.groovy
import com.example.java.DemoClass;
demo = new DemoClass()
println demo.fieldProperty
println demo.cppProperty()
println demo.javaProperty
demo.fieldProperty = "new"
demo.cppProperty("new")
demo.javaProperty = "new"
println demo.fieldProperty
println demo.cppProperty()
println demo.javaProperty
import com.example.java.DemoClass
val demo:DemoClass = DemoClass();
println(demo.fieldProperty)
println(demo.cppProperty())
println(demo.javaProperty)
demo.fieldProperty = "new"
demo.cppProperty("new")
demo.javaProperty = "new"
println(demo.fieldProperty)
println(demo.cppProperty())
println(demo.javaProperty)
import com.example.java.DemoClass
val demo = new DemoClass
demo.fieldProperty
demo.cppProperty
demo.getJavaProperty
demo.fieldProperty = "new"
demo.cppProperty("new")
demo.setJavaProperty("new")
demo.fieldProperty
demo.cppProperty
demo.getJavaProperty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment