[rules-users] Difference between adding $ at the beginning of a variable
Mark Proctor
mproctor at codehaus.org
Thu Jan 17 21:38:30 EST 2013
It mostly helps to differentiate bindings from fields
Person( name : name )
Person( name == name )
This is generally more readable.
Person( $name : name )
Person( name == $name )
That said I prefer to only bind patterns, and if the class name does not conflict with any field names, then I don't use $
p : Person()
Person( name == p.name )
AI systems traditionally use ? to differentiate variables, but that symbol is not allowed as a variable name char in java.
Mark
On 15 Jan 2013, at 20:10, Michael Anstis <michael.anstis at gmail.com> wrote:
> No difference, it was/is just used a lot in examples and advice given on here so has sort of become an unofficial standard.
>
> Some argue the presence of "$" helps identify bindings when scanning DRL.
>
> On 15 January 2013 20:04, suddeb <sudipta.deb at gmail.com> wrote:
> Hi,
> As I am very new to Drools, could you please tell me what is the difference
> between adding a $ at the beginning of a variable and without $.
> For example:
> rule "validate holiday"
> when
> *$h1 : Holiday( `when` == "july" )*
> then
> ......
> end
>
> and
>
> rule "validate holiday"
> when
> *h1 : Holiday( `when` == "july" )*
> then
> ......
> end
>
> Regards,
> Sudipta Deb
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Difference-between-adding-at-the-beginning-of-a-variable-tp4021549.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130118/63880698/attachment.html
More information about the rules-users
mailing list