Need to write a Generic method which returns a list of data objects obtained from wrapper objects (passed to it)
Tag : chash , By : Puneet Madaan
Date : March 29 2020, 07:55 AM
will help you Ok, so basically I need to create a generic method which takes a list of frontend objects, retrieves the wrapped data object of each frontend object and returns a list of data objects. , I would make the FrontEnd objects implement an interface like below: public interface IFrontEndEntity<TEntity>
{
TEntity GetEntity();
}
public static class FrontEndExtensions
{
public static IEnumerable<TEntity> GetEntities<TEntity>(this IEnumerable<IFrontEndEntity<TEntity>> frontEndItems)
{
return frontEndItems.Select(a => a.GetEntity());
}
}
public class Dog
{
}
public class DogFrontEnd : IFrontEndEntity<Dog>
{
public Dog Entity { get; set; }
public Dog GetEntity()
{
return Entity;
}
}
public class Main
{
public void Run()
{
IEnumerable<DogFrontEnd> dogFronEnds = new List<DogFrontEnd>();
IEnumerable<Dog> dogs = dogFronEnds.GetEntities();
}
}
|
How to get lapply to output 2 objects obtained from a function
Tag : r , By : platformNomad
Date : March 29 2020, 07:55 AM
hope this fix your issue I'm trying to lapply a function over a list. Because my function intends to output 2 objects, I'm running into a problem. For each item in the list, running the function only outputs results from the second object. , The function is returning just the last line as it should. Try: test<-function(x){
a<-x+4
b<-x/34
return(c(a,b))
}
list<-c(3,4,5,6,6)
lapply(list,test)
|
How can I write large output to Process getOutputStream?
Tag : java , By : mediafarm
Date : March 29 2020, 07:55 AM
|
How does the getOutputStream method of the Process class work?
Tag : java , By : rhinojosa
Date : March 29 2020, 07:55 AM
|
Output process - save data in file
Date : March 29 2020, 07:55 AM
|