Asking for code review - contract programming

Vinod K Chandran kcvinu82 at gmail.com
Sun Jan 23 22:22:08 UTC 2022


On Sunday, 23 January 2022 at 15:52:49 UTC, Ali Çehreli wrote:
> On 1/23/22 07:33, chopchop wrote:
>
There is language called Odin. I just translated the example code 
of 'out' keyword from your book into Odin. See this--
```D
daysInFebruary :: proc(year : int) -> (result : int) {
	defer assert((result == 28 ) || (result == 29), "Only 28 or 29 
is allowed")
	return isLeapYear(year) ? 29 :  28
}
```
Odin using named return values. Defer keyword ensures the 
execution will be occur at the end of the function execution.


More information about the Digitalmars-d mailing list