Re: [Vala] Generics and Contract Programming



Ah ok, it was the "of T" that I wasn't sure how to do.

Thank you,

Chris


On 06/24/11 13:48, Nicolas wrote:
Hi Chris,

1) For assertations, try this:

[indent=4]

def static foo (ref args : array of string, opts : T, ...) of T
    requires (args.length > 1)
    // do something

init
    print "hello world"

2) For generics, try this:

[indent=4]

class Wrapper of G : GLib.Object

    data : private G

    def set_data(data : G)
        this.data = data

    def get_data() : G
        return this.data

init
    var wrapper = new Wrapper of string
    wrapper.set_data("test")
    var data = wrapper.get_data()

Regards,
Nicolas.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]