Roberto Fernandez
01/11/2018, 5:33 PMfun getView(cardGraphs: List<Graph>): View {
val graphsContainer = RelativeLayout(context)
graphsContainer.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
cardGraphs.fold(null) { view: View?, graph: Graph ->
return addView(graphsContainer, view, getView(graph))
}
return graphsContainer
}
With this code, my function getView (the main function) is returning whatever is the first return of the addView() inside fold..If i set return@fold it needs return Nothing? but my method addView() returns View so it has a type parameter errors..
Can someone explain what is happening here in both cases? and why?Czar
01/11/2018, 5:46 PMreturn
in your fold, it returns from getVeiw
as it should, if you want to fold, just have addView
in there without return
Roberto Fernandez
01/11/2018, 5:48 PMCzar
01/11/2018, 5:49 PMRoberto Fernandez
01/11/2018, 5:50 PMCzar
01/11/2018, 5:50 PM