Last active
October 4, 2018 15:10
-
-
Save shemnon/82b77b633ccbc7fa2adc8c4380e68edf to your computer and use it in GitHub Desktop.
Comparison of property access patterns and JVM language integrations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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