Skip to content

Instantly share code, notes, and snippets.

@benhlal
Created August 24, 2021 18:01
Show Gist options
  • Select an option

  • Save benhlal/10d390ec01c1439cef934d177e1ab459 to your computer and use it in GitHub Desktop.

Select an option

Save benhlal/10d390ec01c1439cef934d177e1ab459 to your computer and use it in GitHub Desktop.
pattern matching instanceof
//Before
if (person instanceof Student) {
Student student = (Student) person;
student.subscribeToCourse();
}
//After
if(obj instanceof Student student) student.subscribeToCourse();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment