Well, it’s debatable if this would be simpler considering you’d introduce a new 
syntax. However I agree that inferred return type would be great.

If we can do:

var aProperty = 10

It would be nice to be able to do

var anotherProperty { foo * 2 }

— Radek

> On 21 Dec 2015, at 08:52, ilya <[email protected]> wrote:
> 
> For those simple computed var cases I wonder if we could use a simpler 
> definition, inferring the type:
> 
> var twiceSomething => something * 2 
> 
> On the other hand,  it's better to specify types for names that can be 
> visible outside of current scope explicitly. So may be the getter declared 
> via this syntax should always be private. 
> 
> On Sun, Dec 20, 2015 at 23:29 Radosław Pietruszewski 
> <[email protected] <mailto:[email protected]>> wrote:
> I honestly don’t have a problem with having to say `return` inside functions. 
> That’s not necessarily a -1, but I’m reluctant to say +1 when _even I_ don’t 
> really have the problem with extra verbosity.
> 
> *However*, as others pointed out, having to type `return` is a bit tiring in 
> the context of a computer property’s “get”:
> 
>> var twiceSomething: Int { self.something * 2 }
> 
> — Radek
> 
>> On 19 Dec 2015, at 14:30, Craig Cruden via swift-evolution 
>> <[email protected] <mailto:[email protected]>> wrote:
>> 
>> 
>> When writing short functional code in a function it would be nice if the 
>> return keyword were an optional keyword. 
>> 
>> Just return the last evaluated expression.
>> 
>> 
>> i.e.
>> 
>>     func flipFunc<T, U>(arg1: T, arg2: U) -> (U, T) {
>>         (arg2, arg1)
>>     }
>> 
>> 
>> The keyword return would still be there for breaking out of a function.
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to