Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Created October 12, 2024 05:08
Show Gist options
  • Save gyugyu90/6ca0341dae561ecfac62dfc0dd47b881 to your computer and use it in GitHub Desktop.
Save gyugyu90/6ca0341dae561ecfac62dfc0dd47b881 to your computer and use it in GitHub Desktop.
class Tea {
String teaBag = "얼그레이";
Milk? milk;
String getFullName() {
if (milk != null) {
return "$teaBag 밀크티";
}
return "$teaBag 티";
}
}
class Milk {
String name = "서울우유";
int amount = 100;
}
void main() {
var tea = Tea();
print(tea.getFullName()); // 얼그레이 티
tea.teaBag = "캐모마일";
tea.milk = Milk();
print(tea.getFullName()); // 캐모마일 밀크티
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment