Skip to content
Advertisement

pass a string as argument in instance of a class, should have method that take string as an arg and perform according to instance.method

I want to create a instance of class Token that takes a string as an argument, this class should also have method punc that tokenize the string according to the method.instance. or raise an not implement error with a message. Problem is that I am new to OOP, class, attribute. I don’t know how to pass the string as an argument and method will work on the string according to the string passed in class instance.

JavaScript
JavaScript

output I get a-z which is not the right one. I know the coding is wrong, since I really not sure how to pass string as an argument. Any help will be appreciated :)

Advertisement

Answer

Are you looking for something like this?

JavaScript

result:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement