Komentarze (8)
@hapaczuri Moim zdaniem jeżeli interface nie ma domyślnej implementacji metody, to nie zachodzi przesłonięcie - bo jakby nie patrzeć nie ma implementacji, którą możesz przesłaniać - jeżeli jej nie zaimplementujesz, to się wy⁎⁎⁎ie
A z drugiej strony dodaje się @Override ¯\_( ͡° ͜ʖ ͡°)_/¯
Edit. po poniższych odpowiedziach, chyba nieprawidłowo zrozumiałem pytanie
@hapaczuri a można po angielsku? Co to jest przesłonięcie? Chodzi o method override?
@globalbus @baklazan chodzi o override
@hapaczuri o matko, zakładałem że mówisz o tym: https://pl.m.wikipedia.org/wiki/Przes%C5%82anianie ; D
Serio, IT jest po angielsku, wywalam angielszczyzny skąd się da, ale nie w języku branżowym, właśnie z powodu powyższego.
W takim razie odpowiedź brzmi: Tak. To jest klasyczny polimorfizm dynamiczny.
@hapaczuri Nie. Przesłonięcie polega na tym że w lokalnej przestrzeni nazw jedna nazwa przesłania inną. Tutaj obie nazwy (Interfejs.metoda i Klasa.metoda) są dalej widoczne tak jak były.
Dla czytających później: jednak opowi chodziło o coś innego niż "variable shadowing"
CC: @LondoMollari
@hapaczuri podaj snippet ^_^'
Zaloguj się aby komentować
@globalbus Zakładam że OPowi chodzi o https://en.wikipedia.org/wiki/Variable_shadowing
Variable shadowing
In computer programming, variable shadowing occurs when a variable declared within a certain scope (decision block, method, or inner class) has the same name as a variable declared in an outer scope. At the level of identifiers (names, rather than variables), this is known as name masking. This outer variable is said to be shadowed by the inner variable, while the inner identifier is said to mask the outer identifier. This can lead to confusion, as it may be unclear which variable subsequent uses of the shadowed variable name refer to, which depends on the name resolution rules of the language. One of the first languages to introduce variable shadowing was ALGOL, which first introduced blocks to establish scopes. It was also permitted by many of the derivative programming languages including C, C++ and Java. The C# language breaks this tradition, allowing variable shadowing between an inner and an outer class, and between a method and its containing class...