LLD - Behavioral Design Patterns — Part 2
Consider the following pseudocode implementing the Interpreter pattern:
class TerminalExpression:
def __init__(self, value):
self.value = value
def interpret(self, context):
return self.value == context
class AndExpression:
def __init__(self, expr1, expr2):
self.expr1 = expr1
self.expr2 = expr2
def interpret(self, context):
return self.expr1.interpret(context) and self.expr2.interpret(context)
context = 'X'
expr = AndExpression(TerminalExpression('X'), TerminalExpression('Y'))
print(expr.interpret(context))What will be the output of this code?