Using toIterable.FindFirst in Generator [message #997288] |
Fri, 04 January 2013 19:00  |
Eclipse User |
|
|
|
Newbie question using a simplified example.
Assuming the following Xtext grammar rules:
LibraryResource: 'Resource' name=QualifiedName dsl_Resource_Properties+=Property*;
Property: name=QualifiedName '=' dsl_Property_Text=STRING
And, assuming that among a number of resources there is one as follows:
Resource abc
size = "large"
color = "blue"
Within MyDslGenerator, I want to use findFirst() to get value of
the Property whose name = size
from the resource whose name = abc.
For example,
val item = resource.resourceSet.allContents.toIterable.findFirst(????????)
I see that findFirst expects Iterable<T>, Function1<? super T, Boolean>
But, I have no clue as to how to supply this. I have spend hours, in vain, trying to find an example.
Thank you in advance for taking time to provide me an example of how to use the findFirst function in the context of IterableExtensions.
|
|
|
|
Re: Using toIterable.FindFirst in Generator [message #997765 is a reply to message #997612] |
Tue, 08 January 2013 12:42  |
Eclipse User |
|
|
|
I was able to successfully use this. Thank you for taking the time to answer! I know that you are all very busy, and I appreciate the fact that you are willing to help out with what to you must be very elementary. But, for those of us starting out, it can be very frustrating trying to figure out how to do certain things. I realized that part of the problem is a lack of experience in functional programming. By looking into that as a topic, I better understand what Xtend is capable of.
|
|
|
Powered by
FUDForum. Page generated in 0.03549 seconds