[swift-evolution] Protocols and var { get }

Dmitri Gribenko gribozavr at gmail.com
Fri Jan 29 18:21:05 CST 2016


On Fri, Jan 29, 2016 at 4:16 PM, Frank Ecsedy via swift-evolution
<swift-evolution at swift.org> wrote:
> I posted this on Erica Sadun's website and she suggested I post it here:
>
> So what about protocols requiring ‘var … { get }’ syntax for read only
> properties? Is there some sort of underlying reason for this confusing
> syntax instead of ‘let …’? Now that Swift allows deferred initialization of
> lets does this requirement make sense?

Computed properties, even get-only ones, can return different values
every time.  'let's can't.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list