News for hackers. Stuff that matters.
Re:Why Does “=” Mean Assignment? by thalesmello on Tuesday April 10, 2018 @07:26PM (#16806618)
`->` is a bad practice? I like to use it at the end of a long `%>%` pipe. Reading the whole thing feels a lot more natural.
Re:Why Does “=” Mean Assignment? by chasedehan on Wednesday April 11, 2018 @11:32AM (#16812172)
The first time I ever saw that you could do that was in a blog post about stringing at the end of the a series of pipes. I thought it was pretty neat (and actually used it a couple times), then had problems when I couldn't figure out why my code was messing up.

for example, this assigns a ggplot to 'plot': df %>% na.omit() %>% ggplot(aes(x=x, y=y)) + geom_line() -> plot

That is really confusing in that the way most people would read it is that it is something to be plotted. However, the assignment does occur and is masked. having 'plot <- df %>%' as the first line makes it clear that a new object is being created.

We actually had to modify our style guide to prevent the '->'

Re:Why Does “=” Mean Assignment? by lionel- on Wednesday April 11, 2018 @05:41AM (#16809461)
It is bad practice because you are hiding the side effect.