is it better to say final type variable or say final variable according to memory management

Saifallak :

i know that var in many languages takes more ram than saying the explicit type but it's different in final situation.

final i = 10; // without type
final int i = 10; // with type

// which is better? or there is no difference at all ?

i searched a little and saw lint always_specify_types, so it's in dart effective dart, but does this include final variables ?

Richard Heap :

As far as the compiler is concerned, those two lines are identical. The compiler infers the type from the right hand side. (You should even be able to hover over the i in the first line in the IDE and it will show you that it's an int.)

So, now it's a matter of style. Do you prefer the Flutter style approach, or the omit local types approach?

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=397491&siteId=1