If I define a Ruby functions like this:
def ldap_get ( base_dn, filter, scope=LDAP::LDAP_SCOPE_SUBTREE, attrs=nil )
How can I call it supplying only the first 2 and the last args? Why isn’t something like
ldap_get( base_dn, filter, , X)
possible or if it is possible, how can it be done?
This isn’t possible with ruby currently. You can’t pass ’empty’ attributes to methods. The closest you can get is to pass nil:
However, this will set the scope to nil, not LDAP::LDAP_SCOPE_SUBTREE.
What you can do is set the default value within your method:
Now if you call the method as above, the behaviour will be as you expect.