Skip to content

Instantly share code, notes, and snippets.

@freakboy3742
Created December 11, 2015 12:14
Show Gist options
  • Save freakboy3742/03e050ac573b57ede73b to your computer and use it in GitHub Desktop.
Save freakboy3742/03e050ac573b57ede73b to your computer and use it in GitHub Desktop.
Another VOC milestone
class MyStringAnalog(implements=java.lang.CharSequence):
def __init__(self, value):
self.value = value
def charAt(self, index: int) -> char:
return 'x'
def length(self) -> int:
return len(self.value)
def subSequence(self, start: int, end: int) -> java.lang.CharSequence:
return MyStringAnalog(self.value[start:end])
def toString(self) -> java.lang.String:
return self.value
from java.lang import StringBuilder
builder = StringBuilder()
builder.append("Hello, ")
analog = MyStringAnalog("world")
builder.append(analog)
print(builder)
@mjtamlyn
Copy link

Should charAt not return self.value[index]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment