Questions tagged [splat]

The `*` operator as used in Ruby. So called because it looks like an insect that's splatted on a windscreen.

The * operator as used in Ruby. So called because it looks like an insect that's splatted on a windscreen.

166 questions
1
vote
2 answers

Splat in argument position

Why does this code Hash[*[[:first_name, 'Shane'], [:last_name, 'Harvie']].flatten] return this {:first_name=>"Shane", :last_name=>"Harvie"} I know about Array#flatten. But what does the * mean? How can I look for information about it?
barak
  • 869
  • 1
  • 11
  • 15
1
vote
1 answer

ActiveRecord Move All Children to Another Record

I have a table with five different has-many relationships to other tables. Before deleting a record, I need to move all of its children to another record. To accomplish this I employ the following…
Jack R-G
  • 1,778
  • 2
  • 19
  • 25
0
votes
1 answer

How does generator * / splat unpacking work?

Let's say I have some function f that will accept a variable number of arguments: def f(*args): for a in args: print(a) Below I call on this function three ways: Case 1: Passing in a generator expression without parenthesis: f(l for l…
Collin
  • 254
  • 1
  • 9
0
votes
1 answer

How can I splat/unpack/apply an array of arguments into a function?

If I have an Excel Array {2023;3;16} how can I apply that to a function like DATE? In python I'd splat using *: DATE(*TEXTSPLIT(A1,".")) In Excel, do I have to manually unpack it with TAKE or INDEX? For example: =LET(a, {2023;3;16}, DATE(INDEX(a,1),…
0
votes
3 answers

Python Creating a function with unkown number arguments with splat operator

I am am trying to round numbers in a dataframe that has lists as values for each row. I need whole numbers to have no decimal and floats to only have two places after the decimal. There is an unknown number of values for each list (some lists have 2…
Shawn Jamal
  • 170
  • 8
0
votes
1 answer

Python splat/unpacking/* operator on sets: is the result always sorted?

Does the splat/unpacking operator * always sort when applied to sets of ints? Example 1 (ints): In [1]: [*{8,3,6,3,2,1}] Out[1]: [1, 2, 3, 6, 8] Counter Example 2 (strings): In [615]: [*{'b','d','a','c','e'}] Out[615]: ['a', 'd', 'c', 'b',…
emj
  • 45
  • 4
0
votes
1 answer

In ReactiveUI, how to call GetService for MutableDependencyResolver

I am reading the book You, I and ReactiveUI and my question relates to the source code for the book at https://github.com/kentcb/YouIandReactiveUI. The versions of ReactiveUI and Splat have changed since the code was published and one portion of the…
VinceL
  • 299
  • 1
  • 3
  • 13
0
votes
1 answer

Why do rails jobs (ApplicationJob) use splat operator?

I've created my first job using the rails generator: rails g job do_something which created the job file: class DoSomethingJob < ApplicationJob queue_as :default def perform(*args) # Do something later end end The splat operator is new…
Clark Taylor
  • 323
  • 2
  • 10
0
votes
1 answer

Why was I able to get away with not using a splat operator sometimes

I have some ruby code from my Ruby on Rails project. I am formatting some data so I am calling attributes.extract! to get the fields I need from my model. I noticed recently that every now and then the data wouldn't get extracted as expected. I…
Gabriel
  • 621
  • 7
  • 19
0
votes
1 answer

Login Screen before Master Detail View in Xamarin

I am trying to write a xamarin app that will display a login page before a master detail page but I am running into issues. Right now I have my app.xaml calling an appbootstrapper as follows: public App() { …
JWalli
  • 9
  • 2
0
votes
1 answer

Visual Studio can't find extension methods Splat.BitmapMixins.FromNative() and Splat.BitmapMixins.ToNative() in Android app

While upgrading a Xamarin app that leverages Splat's bitmap functionality we are getting errors around the use of the methods mentioned in the title: 'IBitmap' does not contain a definition for 'ToNative' and no accessible extension method…
h0meBrewer
  • 31
  • 5
0
votes
1 answer

How does passing "...: $someVariable" work, what is this technique called, and where can I learn more?

I came across this as part of some Laravel PHP code on YouTube. It does work, it's on a fresh install of vanilla Laravel 6, and the instructor appears to be using PHPStorm IDE: dd( ...vars: $paymentGateway->charge( amount:2500)); I am aware of the…
0
votes
1 answer

How to set up logging in splat ReactiveUI?

I need to enable logging in reactiveui. I implemented the ILogger interface: public class Logger : Splat.ILogger { public LogLevel Level { get; private set; } public Logger(LogLevel level) { Level = level; } public void…
Igor. A
  • 73
  • 10
0
votes
1 answer

Ruby 1.9.2 - multiple splat argument issue

New to Ruby and working on a problem where I'm trying to accept multiple splat arguments in the method. I think I understand why it's giving me the compile error, but I'm not sure how to fix it. Any help with how to use multiple splats in the…
Gavin
  • 81
  • 7
0
votes
1 answer

ReactiveUI Register Multiple Assemblies with Splat?

Is it possible to register multiple assemblies containing modules of registrations,, using ReactiveUI/Splat? Something like: Locator.CurrentMutable.RegisterAssemblies(typeof(CommonModule).Assembly, typeof(WindowsModule).Assembly));
Michael C.
  • 93
  • 7